lexical 0.11.0 → 0.11.2
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 +557 -138
- package/Lexical.js.flow +9 -9
- package/Lexical.prod.js +207 -204
- package/LexicalCommands.d.ts +4 -4
- package/LexicalEditor.d.ts +41 -35
- package/LexicalEvents.d.ts +1 -1
- package/LexicalGC.d.ts +1 -1
- package/LexicalNode.d.ts +10 -10
- package/LexicalReconciler.d.ts +1 -1
- package/LexicalSelection.d.ts +148 -6
- package/LexicalUpdates.d.ts +1 -1
- package/LexicalUtils.d.ts +2 -1
- package/nodes/LexicalElementNode.d.ts +2 -2
- package/nodes/LexicalGridCellNode.d.ts +1 -1
- package/nodes/LexicalLineBreakNode.d.ts +1 -1
- package/nodes/LexicalParagraphNode.d.ts +1 -1
- package/nodes/LexicalRootNode.d.ts +1 -1
- package/nodes/LexicalTabNode.d.ts +1 -1
- package/nodes/LexicalTextNode.d.ts +195 -6
- package/package.json +1 -1
package/LexicalCommands.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import type { ElementFormatType, LexicalCommand, TextFormatType } from 'lexical';
|
|
9
|
-
export
|
|
9
|
+
export type PasteCommandType = ClipboardEvent | InputEvent | KeyboardEvent;
|
|
10
10
|
export declare function createCommand<T>(type?: string): LexicalCommand<T>;
|
|
11
11
|
export declare const SELECTION_CHANGE_COMMAND: LexicalCommand<void>;
|
|
12
12
|
export declare const CLICK_COMMAND: LexicalCommand<MouseEvent>;
|
|
@@ -15,7 +15,7 @@ export declare const INSERT_LINE_BREAK_COMMAND: LexicalCommand<boolean>;
|
|
|
15
15
|
export declare const INSERT_PARAGRAPH_COMMAND: LexicalCommand<void>;
|
|
16
16
|
export declare const CONTROLLED_TEXT_INSERTION_COMMAND: LexicalCommand<InputEvent | string>;
|
|
17
17
|
export declare const PASTE_COMMAND: LexicalCommand<PasteCommandType>;
|
|
18
|
-
export declare const REMOVE_TEXT_COMMAND: LexicalCommand<
|
|
18
|
+
export declare const REMOVE_TEXT_COMMAND: LexicalCommand<InputEvent | null>;
|
|
19
19
|
export declare const DELETE_WORD_COMMAND: LexicalCommand<boolean>;
|
|
20
20
|
export declare const DELETE_LINE_COMMAND: LexicalCommand<boolean>;
|
|
21
21
|
export declare const FORMAT_TEXT_COMMAND: LexicalCommand<TextFormatType>;
|
|
@@ -42,8 +42,8 @@ export declare const FORMAT_ELEMENT_COMMAND: LexicalCommand<ElementFormatType>;
|
|
|
42
42
|
export declare const DRAGSTART_COMMAND: LexicalCommand<DragEvent>;
|
|
43
43
|
export declare const DRAGOVER_COMMAND: LexicalCommand<DragEvent>;
|
|
44
44
|
export declare const DRAGEND_COMMAND: LexicalCommand<DragEvent>;
|
|
45
|
-
export declare const COPY_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent>;
|
|
46
|
-
export declare const CUT_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent>;
|
|
45
|
+
export declare const COPY_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent | null>;
|
|
46
|
+
export declare const CUT_COMMAND: LexicalCommand<ClipboardEvent | KeyboardEvent | null>;
|
|
47
47
|
export declare const CLEAR_EDITOR_COMMAND: LexicalCommand<void>;
|
|
48
48
|
export declare const CLEAR_HISTORY_COMMAND: LexicalCommand<void>;
|
|
49
49
|
export declare const CAN_REDO_COMMAND: LexicalCommand<boolean>;
|
package/LexicalEditor.d.ts
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
import type { EditorState, SerializedEditorState } from './LexicalEditorState';
|
|
9
9
|
import type { DOMConversion, NodeKey } from './LexicalNode';
|
|
10
10
|
import { LexicalNode } from './LexicalNode';
|
|
11
|
-
export
|
|
12
|
-
export
|
|
11
|
+
export type Spread<T1, T2> = Omit<T2, keyof T1> & T1;
|
|
12
|
+
export type Klass<T extends LexicalNode> = {
|
|
13
13
|
new (...args: any[]): T;
|
|
14
14
|
} & Omit<LexicalNode, 'constructor'>;
|
|
15
|
-
export
|
|
16
|
-
export
|
|
15
|
+
export type EditorThemeClassName = string;
|
|
16
|
+
export type TextNodeThemeClasses = {
|
|
17
17
|
base?: EditorThemeClassName;
|
|
18
18
|
bold?: EditorThemeClassName;
|
|
19
19
|
code?: EditorThemeClassName;
|
|
@@ -25,19 +25,19 @@ export declare type TextNodeThemeClasses = {
|
|
|
25
25
|
underline?: EditorThemeClassName;
|
|
26
26
|
underlineStrikethrough?: EditorThemeClassName;
|
|
27
27
|
};
|
|
28
|
-
export
|
|
28
|
+
export type EditorUpdateOptions = {
|
|
29
29
|
onUpdate?: () => void;
|
|
30
30
|
skipTransforms?: true;
|
|
31
31
|
tag?: string;
|
|
32
32
|
discrete?: true;
|
|
33
33
|
};
|
|
34
|
-
export
|
|
34
|
+
export type EditorSetOptions = {
|
|
35
35
|
tag?: string;
|
|
36
36
|
};
|
|
37
|
-
export
|
|
37
|
+
export type EditorFocusOptions = {
|
|
38
38
|
defaultSelection?: 'rootStart' | 'rootEnd';
|
|
39
39
|
};
|
|
40
|
-
export
|
|
40
|
+
export type EditorThemeClasses = {
|
|
41
41
|
blockCursor?: EditorThemeClassName;
|
|
42
42
|
characterLimit?: EditorThemeClassName;
|
|
43
43
|
code?: EditorThemeClassName;
|
|
@@ -96,12 +96,12 @@ export declare type EditorThemeClasses = {
|
|
|
96
96
|
indent?: EditorThemeClassName;
|
|
97
97
|
[key: string]: any;
|
|
98
98
|
};
|
|
99
|
-
export
|
|
99
|
+
export type EditorConfig = {
|
|
100
100
|
disableEvents?: boolean;
|
|
101
101
|
namespace: string;
|
|
102
102
|
theme: EditorThemeClasses;
|
|
103
103
|
};
|
|
104
|
-
export
|
|
104
|
+
export type CreateEditorArgs = {
|
|
105
105
|
disableEvents?: boolean;
|
|
106
106
|
editorState?: EditorState;
|
|
107
107
|
namespace?: string;
|
|
@@ -117,19 +117,19 @@ export declare type CreateEditorArgs = {
|
|
|
117
117
|
editable?: boolean;
|
|
118
118
|
theme?: EditorThemeClasses;
|
|
119
119
|
};
|
|
120
|
-
export
|
|
121
|
-
export
|
|
120
|
+
export type RegisteredNodes = Map<string, RegisteredNode>;
|
|
121
|
+
export type RegisteredNode = {
|
|
122
122
|
klass: Klass<LexicalNode>;
|
|
123
123
|
transforms: Set<Transform<LexicalNode>>;
|
|
124
124
|
replace: null | ((node: LexicalNode) => LexicalNode);
|
|
125
125
|
replaceWithKlass: null | Klass<LexicalNode>;
|
|
126
126
|
};
|
|
127
|
-
export
|
|
128
|
-
export
|
|
129
|
-
export
|
|
130
|
-
export
|
|
131
|
-
export
|
|
132
|
-
export
|
|
127
|
+
export type Transform<T extends LexicalNode> = (node: T) => void;
|
|
128
|
+
export type ErrorHandler = (error: Error) => void;
|
|
129
|
+
export type MutationListeners = Map<MutationListener, Klass<LexicalNode>>;
|
|
130
|
+
export type MutatedNodes = Map<Klass<LexicalNode>, Map<NodeKey, NodeMutation>>;
|
|
131
|
+
export type NodeMutation = 'created' | 'updated' | 'destroyed';
|
|
132
|
+
export type UpdateListener = (arg0: {
|
|
133
133
|
dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>;
|
|
134
134
|
dirtyLeaves: Set<NodeKey>;
|
|
135
135
|
editorState: EditorState;
|
|
@@ -137,22 +137,22 @@ export declare type UpdateListener = (arg0: {
|
|
|
137
137
|
prevEditorState: EditorState;
|
|
138
138
|
tags: Set<string>;
|
|
139
139
|
}) => void;
|
|
140
|
-
export
|
|
141
|
-
export
|
|
142
|
-
export
|
|
143
|
-
export
|
|
140
|
+
export type DecoratorListener<T = never> = (decorator: Record<NodeKey, T>) => void;
|
|
141
|
+
export type RootListener = (rootElement: null | HTMLElement, prevRootElement: null | HTMLElement) => void;
|
|
142
|
+
export type TextContentListener = (text: string) => void;
|
|
143
|
+
export type MutationListener = (nodes: Map<NodeKey, NodeMutation>, payload: {
|
|
144
144
|
updateTags: Set<string>;
|
|
145
145
|
dirtyLeaves: Set<string>;
|
|
146
146
|
}) => void;
|
|
147
|
-
export
|
|
148
|
-
export
|
|
149
|
-
export
|
|
147
|
+
export type CommandListener<P> = (payload: P, editor: LexicalEditor) => boolean;
|
|
148
|
+
export type EditableListener = (editable: boolean) => void;
|
|
149
|
+
export type CommandListenerPriority = 0 | 1 | 2 | 3 | 4;
|
|
150
150
|
export declare const COMMAND_PRIORITY_EDITOR = 0;
|
|
151
151
|
export declare const COMMAND_PRIORITY_LOW = 1;
|
|
152
152
|
export declare const COMMAND_PRIORITY_NORMAL = 2;
|
|
153
153
|
export declare const COMMAND_PRIORITY_HIGH = 3;
|
|
154
154
|
export declare const COMMAND_PRIORITY_CRITICAL = 4;
|
|
155
|
-
export
|
|
155
|
+
export type LexicalCommand<TPayload> = {
|
|
156
156
|
type?: string;
|
|
157
157
|
};
|
|
158
158
|
/**
|
|
@@ -175,9 +175,9 @@ export declare type LexicalCommand<TPayload> = {
|
|
|
175
175
|
* }
|
|
176
176
|
* ```
|
|
177
177
|
*/
|
|
178
|
-
export
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
export type CommandPayloadType<TCommand extends LexicalCommand<unknown>> = TCommand extends LexicalCommand<infer TPayload> ? TPayload : never;
|
|
179
|
+
type Commands = Map<LexicalCommand<unknown>, Array<Set<CommandListener<unknown>>>>;
|
|
180
|
+
type Listeners = {
|
|
181
181
|
decorator: Set<DecoratorListener>;
|
|
182
182
|
mutation: MutationListeners;
|
|
183
183
|
editable: Set<EditableListener>;
|
|
@@ -185,12 +185,12 @@ declare type Listeners = {
|
|
|
185
185
|
textcontent: Set<TextContentListener>;
|
|
186
186
|
update: Set<UpdateListener>;
|
|
187
187
|
};
|
|
188
|
-
export
|
|
189
|
-
export
|
|
190
|
-
export
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
export
|
|
188
|
+
export type Listener = DecoratorListener | EditableListener | MutationListener | RootListener | TextContentListener | UpdateListener;
|
|
189
|
+
export type ListenerType = 'update' | 'root' | 'decorator' | 'textcontent' | 'mutation' | 'editable';
|
|
190
|
+
export type TransformerType = 'text' | 'decorator' | 'element' | 'root';
|
|
191
|
+
type IntentionallyMarkedAsDirtyElement = boolean;
|
|
192
|
+
type DOMConversionCache = Map<string, Array<(node: Node) => DOMConversion | null>>;
|
|
193
|
+
export type SerializedEditor = {
|
|
194
194
|
editorState: SerializedEditorState;
|
|
195
195
|
};
|
|
196
196
|
export declare function resetEditor(editor: LexicalEditor, prevRootElement: null | HTMLElement, nextRootElement: null | HTMLElement, pendingEditorState: EditorState): void;
|
|
@@ -357,6 +357,12 @@ export declare class LexicalEditor {
|
|
|
357
357
|
* @returns a teardown function that can be used to cleanup the listener.
|
|
358
358
|
*/
|
|
359
359
|
registerNodeTransform<T extends LexicalNode>(klass: Klass<T>, listener: Transform<T>): () => void;
|
|
360
|
+
/**
|
|
361
|
+
* Used to assert that a certain node is registered, usually by plugins to ensure nodes that they
|
|
362
|
+
* depend on have been registered.
|
|
363
|
+
* @returns True if the editor has registered the provided node type, false otherwise.
|
|
364
|
+
*/
|
|
365
|
+
hasNode<T extends Klass<LexicalNode>>(node: T): boolean;
|
|
360
366
|
/**
|
|
361
367
|
* Used to assert that certain nodes are registered, usually by plugins to ensure nodes that they
|
|
362
368
|
* depend on have been registered.
|
package/LexicalEvents.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { LexicalEditor } from './LexicalEditor';
|
|
9
9
|
import type { NodeKey } from './LexicalNode';
|
|
10
|
-
export
|
|
10
|
+
export type EventHandler = (event: Event, editor: LexicalEditor) => void;
|
|
11
11
|
export declare function addRootElementEvents(rootElement: HTMLElement, editor: LexicalEditor): void;
|
|
12
12
|
export declare function removeRootElementEvents(rootElement: HTMLElement): void;
|
|
13
13
|
export declare function markSelectionChangeFromDOMUpdate(): void;
|
package/LexicalGC.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ import type { LexicalEditor } from './LexicalEditor';
|
|
|
9
9
|
import type { EditorState } from './LexicalEditorState';
|
|
10
10
|
import type { NodeKey } from './LexicalNode';
|
|
11
11
|
export declare function $garbageCollectDetachedDecorators(editor: LexicalEditor, pendingEditorState: EditorState): void;
|
|
12
|
-
|
|
12
|
+
type IntentionallyMarkedAsDirtyElement = boolean;
|
|
13
13
|
export declare function $garbageCollectDetachedNodes(prevEditorState: EditorState, editorState: EditorState, dirtyLeaves: Set<NodeKey>, dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>): void;
|
|
14
14
|
export {};
|
package/LexicalNode.d.ts
CHANGED
|
@@ -8,30 +8,30 @@
|
|
|
8
8
|
import type { EditorConfig, LexicalEditor } from './LexicalEditor';
|
|
9
9
|
import type { GridSelection, NodeSelection, RangeSelection } from './LexicalSelection';
|
|
10
10
|
import { ElementNode } from '.';
|
|
11
|
-
export
|
|
12
|
-
export
|
|
11
|
+
export type NodeMap = Map<NodeKey, LexicalNode>;
|
|
12
|
+
export type SerializedLexicalNode = {
|
|
13
13
|
type: string;
|
|
14
14
|
version: number;
|
|
15
15
|
};
|
|
16
16
|
export declare function removeNode(nodeToRemove: LexicalNode, restoreSelection: boolean, preserveEmptyParent?: boolean): void;
|
|
17
|
-
export
|
|
17
|
+
export type DOMConversion<T extends HTMLElement = HTMLElement> = {
|
|
18
18
|
conversion: DOMConversionFn<T>;
|
|
19
19
|
priority: 0 | 1 | 2 | 3 | 4;
|
|
20
20
|
};
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
export
|
|
21
|
+
export type DOMConversionFn<T extends HTMLElement = HTMLElement> = (element: T) => DOMConversionOutput | null;
|
|
22
|
+
export type DOMChildConversion = (lexicalNode: LexicalNode, parentLexicalNode: LexicalNode | null | undefined) => LexicalNode | null | undefined;
|
|
23
|
+
export type DOMConversionMap<T extends HTMLElement = HTMLElement> = Record<NodeName, (node: T) => DOMConversion<T> | null>;
|
|
24
|
+
type NodeName = string;
|
|
25
|
+
export type DOMConversionOutput = {
|
|
26
26
|
after?: (childLexicalNodes: Array<LexicalNode>) => Array<LexicalNode>;
|
|
27
27
|
forChild?: DOMChildConversion;
|
|
28
28
|
node: null | LexicalNode | Array<LexicalNode>;
|
|
29
29
|
};
|
|
30
|
-
export
|
|
30
|
+
export type DOMExportOutput = {
|
|
31
31
|
after?: (generatedElement: HTMLElement | null | undefined) => HTMLElement | null | undefined;
|
|
32
32
|
element: HTMLElement | null;
|
|
33
33
|
};
|
|
34
|
-
export
|
|
34
|
+
export type NodeKey = string;
|
|
35
35
|
export declare class LexicalNode {
|
|
36
36
|
[x: string]: any;
|
|
37
37
|
/** @internal */
|
package/LexicalReconciler.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import type { LexicalEditor, MutatedNodes } from './LexicalEditor';
|
|
9
9
|
import type { NodeKey } from './LexicalNode';
|
|
10
10
|
import { EditorState } from './LexicalEditorState';
|
|
11
|
-
|
|
11
|
+
type IntentionallyMarkedAsDirtyElement = boolean;
|
|
12
12
|
export declare function reconcileRoot(prevEditorState: EditorState, nextEditorState: EditorState, editor: LexicalEditor, dirtyType: 0 | 1 | 2, dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>, dirtyLeaves: Set<NodeKey>): MutatedNodes;
|
|
13
13
|
export declare function storeDOMWithKey(key: NodeKey, dom: HTMLElement, editor: LexicalEditor): void;
|
|
14
14
|
export {};
|
package/LexicalSelection.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { ElementNode } from './nodes/LexicalElementNode';
|
|
|
12
12
|
import type { TextFormatType } from './nodes/LexicalTextNode';
|
|
13
13
|
import { DEPRECATED_GridCellNode, DEPRECATED_GridNode, DEPRECATED_GridRowNode, TextNode } from '.';
|
|
14
14
|
import { LexicalNode } from './LexicalNode';
|
|
15
|
-
export
|
|
15
|
+
export type TextPointType = {
|
|
16
16
|
_selection: RangeSelection | GridSelection;
|
|
17
17
|
getNode: () => TextNode;
|
|
18
18
|
is: (point: PointType) => boolean;
|
|
@@ -22,7 +22,7 @@ export declare type TextPointType = {
|
|
|
22
22
|
set: (key: NodeKey, offset: number, type: 'text' | 'element') => void;
|
|
23
23
|
type: 'text';
|
|
24
24
|
};
|
|
25
|
-
export
|
|
25
|
+
export type ElementPointType = {
|
|
26
26
|
_selection: RangeSelection | GridSelection;
|
|
27
27
|
getNode: () => ElementNode;
|
|
28
28
|
is: (point: PointType) => boolean;
|
|
@@ -32,13 +32,13 @@ export declare type ElementPointType = {
|
|
|
32
32
|
set: (key: NodeKey, offset: number, type: 'text' | 'element') => void;
|
|
33
33
|
type: 'element';
|
|
34
34
|
};
|
|
35
|
-
export
|
|
36
|
-
export
|
|
35
|
+
export type PointType = TextPointType | ElementPointType;
|
|
36
|
+
export type GridMapValueType = {
|
|
37
37
|
cell: DEPRECATED_GridCellNode;
|
|
38
38
|
startRow: number;
|
|
39
39
|
startColumn: number;
|
|
40
40
|
};
|
|
41
|
-
export
|
|
41
|
+
export type GridMapType = Array<Array<GridMapValueType>>;
|
|
42
42
|
export declare class Point {
|
|
43
43
|
key: NodeKey;
|
|
44
44
|
offset: number;
|
|
@@ -79,7 +79,7 @@ export declare class NodeSelection implements BaseSelection {
|
|
|
79
79
|
getTextContent(): string;
|
|
80
80
|
}
|
|
81
81
|
export declare function $isRangeSelection(x: unknown): x is RangeSelection;
|
|
82
|
-
export
|
|
82
|
+
export type GridSelectionShape = {
|
|
83
83
|
fromX: number;
|
|
84
84
|
fromY: number;
|
|
85
85
|
toX: number;
|
|
@@ -115,29 +115,171 @@ export declare class RangeSelection implements BaseSelection {
|
|
|
115
115
|
style: string;
|
|
116
116
|
_cachedNodes: null | Array<LexicalNode>;
|
|
117
117
|
constructor(anchor: PointType, focus: PointType, format: number, style: string);
|
|
118
|
+
/**
|
|
119
|
+
* Used to check if the provided selections is equal to this one by value,
|
|
120
|
+
* inluding anchor, focus, format, and style properties.
|
|
121
|
+
* @param selection - the Selection to compare this one to.
|
|
122
|
+
* @returns true if the Selections are equal, false otherwise.
|
|
123
|
+
*/
|
|
118
124
|
is(selection: null | RangeSelection | NodeSelection | GridSelection): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Returns whether the Selection is "backwards", meaning the focus
|
|
127
|
+
* logically precedes the anchor in the EditorState.
|
|
128
|
+
* @returns true if the Selection is backwards, false otherwise.
|
|
129
|
+
*/
|
|
119
130
|
isBackward(): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Returns whether the Selection is "collapsed", meaning the anchor and focus are
|
|
133
|
+
* the same node and have the same offset.
|
|
134
|
+
*
|
|
135
|
+
* @returns true if the Selection is collapsed, false otherwise.
|
|
136
|
+
*/
|
|
120
137
|
isCollapsed(): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Gets all the nodes in the Selection. Uses caching to make it generally suitable
|
|
140
|
+
* for use in hot paths.
|
|
141
|
+
*
|
|
142
|
+
* @returns an Array containing all the nodes in the Selection
|
|
143
|
+
*/
|
|
121
144
|
getNodes(): Array<LexicalNode>;
|
|
145
|
+
/**
|
|
146
|
+
* Sets this Selection to be of type "text" at the provided anchor and focus values.
|
|
147
|
+
*
|
|
148
|
+
* @param anchorNode - the anchor node to set on the Selection
|
|
149
|
+
* @param anchorOffset - the offset to set on the Selection
|
|
150
|
+
* @param focusNode - the focus node to set on the Selection
|
|
151
|
+
* @param focusOffset - the focus offset to set on the Selection
|
|
152
|
+
*/
|
|
122
153
|
setTextNodeRange(anchorNode: TextNode, anchorOffset: number, focusNode: TextNode, focusOffset: number): void;
|
|
154
|
+
/**
|
|
155
|
+
* Gets the (plain) text content of all the nodes in the selection.
|
|
156
|
+
*
|
|
157
|
+
* @returns a string representing the text content of all the nodes in the Selection
|
|
158
|
+
*/
|
|
123
159
|
getTextContent(): string;
|
|
160
|
+
/**
|
|
161
|
+
* Attempts to map a DOM selection range onto this Lexical Selection,
|
|
162
|
+
* setting the anchor, focus, and type accordingly
|
|
163
|
+
*
|
|
164
|
+
* @param range a DOM Selection range conforming to the StaticRange interface.
|
|
165
|
+
*/
|
|
124
166
|
applyDOMRange(range: StaticRange): void;
|
|
167
|
+
/**
|
|
168
|
+
* Creates a new RangeSelection, copying over all the property values from this one.
|
|
169
|
+
*
|
|
170
|
+
* @returns a new RangeSelection with the same property values as this one.
|
|
171
|
+
*/
|
|
125
172
|
clone(): RangeSelection;
|
|
173
|
+
/**
|
|
174
|
+
* Toggles the provided format on all the TextNodes in the Selection.
|
|
175
|
+
*
|
|
176
|
+
* @param format a string TextFormatType to toggle on the TextNodes in the selection
|
|
177
|
+
*/
|
|
126
178
|
toggleFormat(format: TextFormatType): void;
|
|
179
|
+
/**
|
|
180
|
+
* Sets the value of the style property on the Selection
|
|
181
|
+
*
|
|
182
|
+
* @param style - the style to set at the value of the style property.
|
|
183
|
+
*/
|
|
127
184
|
setStyle(style: string): void;
|
|
185
|
+
/**
|
|
186
|
+
* Returns whether the provided TextFormatType is present on the Selection. This will be true if any node in the Selection
|
|
187
|
+
* has the specified format.
|
|
188
|
+
*
|
|
189
|
+
* @param type the TextFormatType to check for.
|
|
190
|
+
* @returns true if the provided format is currently toggled on on the Selection, false otherwise.
|
|
191
|
+
*/
|
|
128
192
|
hasFormat(type: TextFormatType): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Attempts to insert the provided text into the EditorState at the current Selection.
|
|
195
|
+
* converts tabs, newlines, and carriage returns into LexicalNodes.
|
|
196
|
+
*
|
|
197
|
+
* @param text the text to insert into the Selection
|
|
198
|
+
*/
|
|
129
199
|
insertRawText(text: string): void;
|
|
200
|
+
/**
|
|
201
|
+
* Attempts to insert the provided text into the EditorState at the current Selection as a new
|
|
202
|
+
* Lexical TextNode, according to a series of insertion heuristics based on the selection type and position.
|
|
203
|
+
*
|
|
204
|
+
* @param text the text to insert into the Selection
|
|
205
|
+
*/
|
|
130
206
|
insertText(text: string): void;
|
|
207
|
+
/**
|
|
208
|
+
* Removes the text in the Selection, adjusting the EditorState accordingly.
|
|
209
|
+
*/
|
|
131
210
|
removeText(): void;
|
|
211
|
+
/**
|
|
212
|
+
* Applies the provided format to the TextNodes in the Selection, splitting or
|
|
213
|
+
* merging nodes as necessary.
|
|
214
|
+
*
|
|
215
|
+
* @param formatType the format type to apply to the nodes in the Selection.
|
|
216
|
+
*/
|
|
132
217
|
formatText(formatType: TextFormatType): void;
|
|
218
|
+
/**
|
|
219
|
+
* Attempts to "intelligently" insert an arbitrary list of Lexical nodes into the EditorState at the
|
|
220
|
+
* current Selection according to a set of heuristics that determine how surrounding nodes
|
|
221
|
+
* should be changed, replaced, or moved to accomodate the incoming ones.
|
|
222
|
+
*
|
|
223
|
+
* @param nodes - the nodes to insert
|
|
224
|
+
* @param selectStart - whether or not to select the start after the insertion.
|
|
225
|
+
* @returns true if the nodes were inserted successfully, false otherwise.
|
|
226
|
+
*/
|
|
133
227
|
insertNodes(nodes: Array<LexicalNode>, selectStart?: boolean): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Inserts a new ParagraphNode into the EditorState at the current Selection
|
|
230
|
+
*/
|
|
134
231
|
insertParagraph(): void;
|
|
232
|
+
/**
|
|
233
|
+
* Inserts a logical linebreak, which may be a new LineBreakNode or a new ParagraphNode, into the EditorState at the
|
|
234
|
+
* current Selection.
|
|
235
|
+
*
|
|
236
|
+
* @param selectStart whether or not to select the start of the insertion range after the operation completes.
|
|
237
|
+
*/
|
|
135
238
|
insertLineBreak(selectStart?: boolean): void;
|
|
239
|
+
/**
|
|
240
|
+
* Returns the character-based offsets of the Selection, accounting for non-text Points
|
|
241
|
+
* by using the children size or text content.
|
|
242
|
+
*
|
|
243
|
+
* @returns the character offsets for the Selection
|
|
244
|
+
*/
|
|
136
245
|
getCharacterOffsets(): [number, number];
|
|
246
|
+
/**
|
|
247
|
+
* Extracts the nodes in the Selection, splitting nodes where necessary
|
|
248
|
+
* to get offset-level precision.
|
|
249
|
+
*
|
|
250
|
+
* @returns The nodes in the Selection
|
|
251
|
+
*/
|
|
137
252
|
extract(): Array<LexicalNode>;
|
|
253
|
+
/**
|
|
254
|
+
* Modifies the Selection according to the parameters and a set of heuristics that account for
|
|
255
|
+
* various node types. Can be used to safely move or extend selection by one logical "unit" without
|
|
256
|
+
* dealing explicitly with all the possible node types.
|
|
257
|
+
*
|
|
258
|
+
* @param alter the type of modification to perform
|
|
259
|
+
* @param isBackward whether or not selection is backwards
|
|
260
|
+
* @param granularity the granularity at which to apply the modification
|
|
261
|
+
*/
|
|
138
262
|
modify(alter: 'move' | 'extend', isBackward: boolean, granularity: 'character' | 'word' | 'lineboundary'): void;
|
|
263
|
+
/**
|
|
264
|
+
* Performs one logical character deletion operation on the EditorState based on the current Selection.
|
|
265
|
+
* Handles different node types.
|
|
266
|
+
*
|
|
267
|
+
* @param isBackward whether or not the selection is backwards.
|
|
268
|
+
*/
|
|
139
269
|
deleteCharacter(isBackward: boolean): void;
|
|
270
|
+
/**
|
|
271
|
+
* Performs one logical line deletion operation on the EditorState based on the current Selection.
|
|
272
|
+
* Handles different node types.
|
|
273
|
+
*
|
|
274
|
+
* @param isBackward whether or not the selection is backwards.
|
|
275
|
+
*/
|
|
140
276
|
deleteLine(isBackward: boolean): void;
|
|
277
|
+
/**
|
|
278
|
+
* Performs one logical word deletion operation on the EditorState based on the current Selection.
|
|
279
|
+
* Handles different node types.
|
|
280
|
+
*
|
|
281
|
+
* @param isBackward whether or not the selection is backwards.
|
|
282
|
+
*/
|
|
141
283
|
deleteWord(isBackward: boolean): void;
|
|
142
284
|
}
|
|
143
285
|
export declare function $isNodeSelection(x: unknown): x is NodeSelection;
|
package/LexicalUpdates.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare function $applyTransforms(editor: LexicalEditor, node: LexicalNod
|
|
|
19
19
|
export declare function $parseSerializedNode(serializedNode: SerializedLexicalNode): LexicalNode;
|
|
20
20
|
export declare function parseEditorState(serializedEditorState: SerializedEditorState, editor: LexicalEditor, updateFn: void | (() => void)): EditorState;
|
|
21
21
|
export declare function readEditorState<V>(editorState: EditorState, callbackFn: () => V): V;
|
|
22
|
-
export declare function commitPendingUpdates(editor: LexicalEditor): void;
|
|
22
|
+
export declare function commitPendingUpdates(editor: LexicalEditor, recoveryEditorState?: EditorState): void;
|
|
23
23
|
export declare function triggerListeners(type: 'update' | 'root' | 'decorator' | 'textcontent' | 'editable', editor: LexicalEditor, isCurrentlyEnqueuingUpdates: boolean, ...payload: unknown[]): void;
|
|
24
24
|
export declare function triggerCommandListeners<TCommand extends LexicalCommand<unknown>>(editor: LexicalEditor, type: TCommand, payload: CommandPayloadType<TCommand>): boolean;
|
|
25
25
|
export declare function updateEditor(editor: LexicalEditor, updateFn: () => void, options?: EditorUpdateOptions): void;
|
package/LexicalUtils.d.ts
CHANGED
|
@@ -84,6 +84,7 @@ export declare function isBackspace(keyCode: number): boolean;
|
|
|
84
84
|
export declare function isEscape(keyCode: number): boolean;
|
|
85
85
|
export declare function isDelete(keyCode: number): boolean;
|
|
86
86
|
export declare function isSelectAll(keyCode: number, metaKey: boolean, ctrlKey: boolean): boolean;
|
|
87
|
+
export declare function $selectAll(): void;
|
|
87
88
|
export declare function getCachedClassNameArray(classNamesTheme: EditorThemeClasses, classNameThemeType: string): Array<string>;
|
|
88
89
|
export declare function setMutatedNode(mutatedNodes: MutatedNodes, registeredNodes: RegisteredNodes, mutationListeners: MutationListeners, node: LexicalNode, mutation: NodeMutation): void;
|
|
89
90
|
export declare function $nodesOfType<T extends LexicalNode>(klass: Klass<T>): Array<T>;
|
|
@@ -96,7 +97,7 @@ export declare function getParentElement(node: Node): HTMLElement | null;
|
|
|
96
97
|
export declare function scrollIntoViewIfNeeded(editor: LexicalEditor, selectionRect: DOMRect, rootElement: HTMLElement): void;
|
|
97
98
|
export declare function $hasUpdateTag(tag: string): boolean;
|
|
98
99
|
export declare function $addUpdateTag(tag: string): void;
|
|
99
|
-
export declare function $maybeMoveChildrenSelectionToParent(parentNode: LexicalNode
|
|
100
|
+
export declare function $maybeMoveChildrenSelectionToParent(parentNode: LexicalNode): RangeSelection | NodeSelection | GridSelection | null;
|
|
100
101
|
export declare function $hasAncestor(child: LexicalNode, targetNode: LexicalNode): boolean;
|
|
101
102
|
export declare function getDefaultView(domElem: HTMLElement): Window | null;
|
|
102
103
|
export declare function getWindow(editor: LexicalEditor): Window;
|
|
@@ -10,13 +10,13 @@ import type { GridSelection, NodeSelection, RangeSelection } from '../LexicalSel
|
|
|
10
10
|
import type { Spread } from 'lexical';
|
|
11
11
|
import { TextNode } from '../';
|
|
12
12
|
import { LexicalNode } from '../LexicalNode';
|
|
13
|
-
export
|
|
13
|
+
export type SerializedElementNode<T extends SerializedLexicalNode = SerializedLexicalNode> = Spread<{
|
|
14
14
|
children: Array<T>;
|
|
15
15
|
direction: 'ltr' | 'rtl' | null;
|
|
16
16
|
format: ElementFormatType;
|
|
17
17
|
indent: number;
|
|
18
18
|
}, SerializedLexicalNode>;
|
|
19
|
-
export
|
|
19
|
+
export type ElementFormatType = 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '';
|
|
20
20
|
/** @noInheritDoc */
|
|
21
21
|
export declare class ElementNode extends LexicalNode {
|
|
22
22
|
/** @internal */
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { LexicalNode, NodeKey, SerializedElementNode, Spread } from 'lexical';
|
|
9
9
|
import { ElementNode } from './LexicalElementNode';
|
|
10
|
-
export
|
|
10
|
+
export type SerializedGridCellNode = Spread<{
|
|
11
11
|
colSpan?: number;
|
|
12
12
|
rowSpan?: number;
|
|
13
13
|
}, SerializedElementNode>;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { DOMConversionMap, NodeKey, SerializedLexicalNode } from '../LexicalNode';
|
|
9
9
|
import { LexicalNode } from '../LexicalNode';
|
|
10
|
-
export
|
|
10
|
+
export type SerializedLineBreakNode = SerializedLexicalNode;
|
|
11
11
|
/** @noInheritDoc */
|
|
12
12
|
export declare class LineBreakNode extends LexicalNode {
|
|
13
13
|
static getType(): string;
|
|
@@ -10,7 +10,7 @@ import type { DOMConversionMap, DOMExportOutput, LexicalNode } from '../LexicalN
|
|
|
10
10
|
import type { SerializedElementNode } from './LexicalElementNode';
|
|
11
11
|
import type { RangeSelection } from 'lexical';
|
|
12
12
|
import { ElementNode } from './LexicalElementNode';
|
|
13
|
-
export
|
|
13
|
+
export type SerializedParagraphNode = SerializedElementNode;
|
|
14
14
|
/** @noInheritDoc */
|
|
15
15
|
export declare class ParagraphNode extends ElementNode {
|
|
16
16
|
static getType(): string;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import type { LexicalNode, SerializedLexicalNode } from '../LexicalNode';
|
|
9
9
|
import type { SerializedElementNode } from './LexicalElementNode';
|
|
10
10
|
import { ElementNode } from './LexicalElementNode';
|
|
11
|
-
export
|
|
11
|
+
export type SerializedRootNode<T extends SerializedLexicalNode = SerializedLexicalNode> = SerializedElementNode<T>;
|
|
12
12
|
/** @noInheritDoc */
|
|
13
13
|
export declare class RootNode extends ElementNode {
|
|
14
14
|
/** @internal */
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import type { DOMConversionMap, NodeKey } from '../LexicalNode';
|
|
9
9
|
import { LexicalNode } from '../LexicalNode';
|
|
10
10
|
import { SerializedTextNode, TextDetailType, TextModeType, TextNode } from './LexicalTextNode';
|
|
11
|
-
export
|
|
11
|
+
export type SerializedTabNode = SerializedTextNode;
|
|
12
12
|
/** @noInheritDoc */
|
|
13
13
|
export declare class TabNode extends TextNode {
|
|
14
14
|
static getType(): string;
|