lexical 0.3.5 → 0.3.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.dev.js +232 -157
- package/Lexical.js.flow +2 -1
- package/Lexical.prod.js +170 -168
- package/LexicalConstants.d.ts +4 -3
- package/LexicalEditor.d.ts +9 -10
- package/LexicalNode.d.ts +7 -7
- package/LexicalSelection.d.ts +6 -6
- package/LexicalUtils.d.ts +6 -7
- package/LexicalVersion.d.ts +1 -1
- package/index.d.ts +1 -1
- package/nodes/LexicalElementNode.d.ts +1 -1
- package/nodes/LexicalTextNode.d.ts +3 -2
- package/package.json +1 -4
package/LexicalConstants.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import type { ElementFormatType } from './nodes/LexicalElementNode';
|
|
9
|
-
import type { TextFormatType, TextModeType } from './nodes/LexicalTextNode';
|
|
9
|
+
import type { TextDetailType, TextFormatType, TextModeType } from './nodes/LexicalTextNode';
|
|
10
10
|
export declare const DOM_ELEMENT_TYPE = 1;
|
|
11
11
|
export declare const DOM_TEXT_TYPE = 3;
|
|
12
12
|
export declare const NO_DIRTY_NODES = 0;
|
|
@@ -35,8 +35,9 @@ export declare const DOUBLE_LINE_BREAK = "\n\n";
|
|
|
35
35
|
export declare const COMPOSITION_START_CHAR: string;
|
|
36
36
|
export declare const RTL_REGEX: RegExp;
|
|
37
37
|
export declare const LTR_REGEX: RegExp;
|
|
38
|
-
export declare const TEXT_TYPE_TO_FORMAT: Record<TextFormatType, number>;
|
|
39
|
-
export declare const
|
|
38
|
+
export declare const TEXT_TYPE_TO_FORMAT: Record<TextFormatType | string, number>;
|
|
39
|
+
export declare const DETAIL_TYPE_TO_DETAIL: Record<TextDetailType | string, number>;
|
|
40
|
+
export declare const ELEMENT_TYPE_TO_FORMAT: Record<Exclude<ElementFormatType, ''>, number>;
|
|
40
41
|
export declare const ELEMENT_FORMAT_TO_TYPE: Record<number, ElementFormatType>;
|
|
41
42
|
export declare const TEXT_MODE_TO_TYPE: Record<TextModeType, 0 | 1 | 2 | 3>;
|
|
42
43
|
export declare const TEXT_TYPE_TO_MODE: Record<number, TextModeType>;
|
package/LexicalEditor.d.ts
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { EditorState, SerializedEditorState } from './LexicalEditorState';
|
|
9
9
|
import type { DOMConversion, LexicalNode, NodeKey } from './LexicalNode';
|
|
10
|
-
import type { Klass } from 'shared/types';
|
|
11
10
|
export declare type Spread<T1, T2> = Omit<T2, keyof T1> & T1;
|
|
11
|
+
export declare type Klass<T extends LexicalNode> = {
|
|
12
|
+
new (...args: any[]): T;
|
|
13
|
+
} & Omit<LexicalNode, 'constructor'>;
|
|
12
14
|
export declare type EditorThemeClassName = string;
|
|
13
15
|
export declare type TextNodeThemeClasses = {
|
|
14
16
|
base?: EditorThemeClassName;
|
|
@@ -30,6 +32,7 @@ export declare type EditorSetOptions = {
|
|
|
30
32
|
tag?: string;
|
|
31
33
|
};
|
|
32
34
|
export declare type EditorThemeClasses = {
|
|
35
|
+
characterLimit?: EditorThemeClassName;
|
|
33
36
|
code?: EditorThemeClassName;
|
|
34
37
|
codeHighlight?: Record<string, EditorThemeClassName>;
|
|
35
38
|
hashtag?: EditorThemeClassName;
|
|
@@ -72,11 +75,7 @@ export declare type EditorThemeClasses = {
|
|
|
72
75
|
base?: EditorThemeClassName;
|
|
73
76
|
focus?: EditorThemeClassName;
|
|
74
77
|
};
|
|
75
|
-
[key: string]:
|
|
76
|
-
[key: string]: Array<EditorThemeClassName> | EditorThemeClassName | TextNodeThemeClasses | {
|
|
77
|
-
[key: string]: EditorThemeClassName;
|
|
78
|
-
};
|
|
79
|
-
};
|
|
78
|
+
[key: string]: any;
|
|
80
79
|
};
|
|
81
80
|
export declare type EditorConfig = {
|
|
82
81
|
disableEvents?: boolean;
|
|
@@ -88,7 +87,7 @@ export declare type RegisteredNode = {
|
|
|
88
87
|
klass: Klass<LexicalNode>;
|
|
89
88
|
transforms: Set<Transform<LexicalNode>>;
|
|
90
89
|
};
|
|
91
|
-
export declare type Transform<T> = (node: T) => void;
|
|
90
|
+
export declare type Transform<T extends LexicalNode> = (node: T) => void;
|
|
92
91
|
export declare type ErrorHandler = (error: Error) => void;
|
|
93
92
|
export declare type MutationListeners = Map<MutationListener, Klass<LexicalNode>>;
|
|
94
93
|
export declare type MutatedNodes = Map<Klass<LexicalNode>, Map<NodeKey, NodeMutation>>;
|
|
@@ -101,7 +100,7 @@ export declare type UpdateListener = (arg0: {
|
|
|
101
100
|
prevEditorState: EditorState;
|
|
102
101
|
tags: Set<string>;
|
|
103
102
|
}) => void;
|
|
104
|
-
export declare type DecoratorListener<T =
|
|
103
|
+
export declare type DecoratorListener<T = never> = (decorator: Record<NodeKey, T>) => void;
|
|
105
104
|
export declare type RootListener = (rootElement: null | HTMLElement, prevRootElement: null | HTMLElement) => void;
|
|
106
105
|
export declare type TextContentListener = (text: string) => void;
|
|
107
106
|
export declare type MutationListener = (nodes: Map<NodeKey, NodeMutation>) => void;
|
|
@@ -113,7 +112,7 @@ export declare const COMMAND_PRIORITY_LOW = 1;
|
|
|
113
112
|
export declare const COMMAND_PRIORITY_NORMAL = 2;
|
|
114
113
|
export declare const COMMAND_PRIORITY_HIGH = 3;
|
|
115
114
|
export declare const COMMAND_PRIORITY_CRITICAL = 4;
|
|
116
|
-
export declare type LexicalCommand<T> = Readonly<Record<string, unknown>>;
|
|
115
|
+
export declare type LexicalCommand<T = never> = Readonly<Record<string, unknown>>;
|
|
117
116
|
declare type Commands = Map<LexicalCommand<unknown>, Array<Set<CommandListener<unknown>>>>;
|
|
118
117
|
declare type Listeners = {
|
|
119
118
|
decorator: Set<DecoratorListener>;
|
|
@@ -151,7 +150,7 @@ export declare class LexicalEditor {
|
|
|
151
150
|
_compositionKey: null | NodeKey;
|
|
152
151
|
_deferred: Array<() => void>;
|
|
153
152
|
_keyToDOMMap: Map<NodeKey, HTMLElement>;
|
|
154
|
-
_updates: Array<[() => void, EditorUpdateOptions]>;
|
|
153
|
+
_updates: Array<[() => void, EditorUpdateOptions | undefined]>;
|
|
155
154
|
_updating: boolean;
|
|
156
155
|
_listeners: Listeners;
|
|
157
156
|
_commands: Commands;
|
package/LexicalNode.d.ts
CHANGED
|
@@ -15,13 +15,13 @@ export declare type SerializedLexicalNode = {
|
|
|
15
15
|
};
|
|
16
16
|
export declare function removeNode(nodeToRemove: LexicalNode, restoreSelection: boolean, preserveEmptyParent?: boolean): void;
|
|
17
17
|
export declare function $getNodeByKeyOrThrow<N extends LexicalNode>(key: NodeKey): N;
|
|
18
|
-
export declare type DOMConversion = {
|
|
19
|
-
conversion: DOMConversionFn
|
|
18
|
+
export declare type DOMConversion<T extends HTMLElement = HTMLElement> = {
|
|
19
|
+
conversion: DOMConversionFn<T>;
|
|
20
20
|
priority: 0 | 1 | 2 | 3 | 4;
|
|
21
21
|
};
|
|
22
|
-
export declare type DOMConversionFn = (element:
|
|
23
|
-
export declare type DOMChildConversion = (lexicalNode: LexicalNode, parentLexicalNode: LexicalNode | null) => LexicalNode | null |
|
|
24
|
-
export declare type DOMConversionMap = Record<NodeName, (node:
|
|
22
|
+
export declare type DOMConversionFn<T extends HTMLElement = HTMLElement> = (element: T, parent?: Node) => DOMConversionOutput | null;
|
|
23
|
+
export declare type DOMChildConversion = (lexicalNode: LexicalNode, parentLexicalNode: LexicalNode | null | undefined) => LexicalNode | null | undefined;
|
|
24
|
+
export declare type DOMConversionMap<T extends HTMLElement = HTMLElement> = Record<NodeName, (node: T) => DOMConversion<T> | null>;
|
|
25
25
|
declare type NodeName = string;
|
|
26
26
|
export declare type DOMConversionOutput = {
|
|
27
27
|
after?: (childLexicalNodes: Array<LexicalNode>) => Array<LexicalNode>;
|
|
@@ -36,7 +36,7 @@ export declare type NodeKey = string;
|
|
|
36
36
|
export declare class LexicalNode {
|
|
37
37
|
[x: string]: any;
|
|
38
38
|
__type: string;
|
|
39
|
-
__key:
|
|
39
|
+
__key: string;
|
|
40
40
|
__parent: null | NodeKey;
|
|
41
41
|
static getType(): string;
|
|
42
42
|
static clone(_data: unknown): LexicalNode;
|
|
@@ -50,7 +50,7 @@ export declare class LexicalNode {
|
|
|
50
50
|
getParentOrThrow<T extends ElementNode>(): T;
|
|
51
51
|
getTopLevelElement(): ElementNode | this | null;
|
|
52
52
|
getTopLevelElementOrThrow(): ElementNode | this;
|
|
53
|
-
getParents
|
|
53
|
+
getParents(): Array<ElementNode>;
|
|
54
54
|
getParentKeys(): Array<NodeKey>;
|
|
55
55
|
getPreviousSibling<T extends LexicalNode>(): T | null;
|
|
56
56
|
getPreviousSiblings<T extends LexicalNode>(): Array<T>;
|
package/LexicalSelection.d.ts
CHANGED
|
@@ -14,9 +14,9 @@ import { TextNode } from '.';
|
|
|
14
14
|
export declare type TextPointType = {
|
|
15
15
|
_selection: RangeSelection | GridSelection;
|
|
16
16
|
getNode: () => TextNode;
|
|
17
|
-
is: (
|
|
17
|
+
is: (point: PointType) => boolean;
|
|
18
18
|
isAtNodeEnd: () => boolean;
|
|
19
|
-
isBefore: (
|
|
19
|
+
isBefore: (point: PointType) => boolean;
|
|
20
20
|
key: NodeKey;
|
|
21
21
|
offset: number;
|
|
22
22
|
set: (key: NodeKey, offset: number, type: 'text' | 'element') => void;
|
|
@@ -25,9 +25,9 @@ export declare type TextPointType = {
|
|
|
25
25
|
export declare type ElementPointType = {
|
|
26
26
|
_selection: RangeSelection | GridSelection;
|
|
27
27
|
getNode: () => ElementNode;
|
|
28
|
-
is: (
|
|
28
|
+
is: (point: PointType) => boolean;
|
|
29
29
|
isAtNodeEnd: () => boolean;
|
|
30
|
-
isBefore: (
|
|
30
|
+
isBefore: (point: PointType) => boolean;
|
|
31
31
|
key: NodeKey;
|
|
32
32
|
offset: number;
|
|
33
33
|
set: (key: NodeKey, offset: number, type: 'text' | 'element') => void;
|
|
@@ -38,7 +38,7 @@ export declare class Point {
|
|
|
38
38
|
key: NodeKey;
|
|
39
39
|
offset: number;
|
|
40
40
|
type: 'text' | 'element';
|
|
41
|
-
_selection: RangeSelection | GridSelection;
|
|
41
|
+
_selection: RangeSelection | GridSelection | null;
|
|
42
42
|
constructor(key: NodeKey, offset: number, type: 'text' | 'element');
|
|
43
43
|
is(point: PointType): boolean;
|
|
44
44
|
isBefore(b: PointType): boolean;
|
|
@@ -84,7 +84,7 @@ export declare class GridSelection implements BaseSelection {
|
|
|
84
84
|
anchor: PointType;
|
|
85
85
|
focus: PointType;
|
|
86
86
|
dirty: boolean;
|
|
87
|
-
_cachedNodes: Array<LexicalNode
|
|
87
|
+
_cachedNodes: Array<LexicalNode> | null;
|
|
88
88
|
constructor(gridKey: NodeKey, anchor: PointType, focus: PointType);
|
|
89
89
|
is(selection: null | RangeSelection | NodeSelection | GridSelection): boolean;
|
|
90
90
|
set(gridKey: NodeKey, anchorCellKey: NodeKey, focusCellKey: NodeKey): void;
|
package/LexicalUtils.d.ts
CHANGED
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import type { LexicalCommand, MutatedNodes, MutationListeners, NodeMutation, RegisteredNode, RegisteredNodes } from './LexicalEditor';
|
|
8
|
+
import type { 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';
|
|
12
12
|
import type { RootNode } from './nodes/LexicalRootNode';
|
|
13
13
|
import type { TextFormatType, TextNode } from './nodes/LexicalTextNode';
|
|
14
|
-
import
|
|
15
|
-
import { ElementNode } from '.';
|
|
14
|
+
import { DecoratorNode, ElementNode, LineBreakNode } from '.';
|
|
16
15
|
import { LexicalEditor } from './LexicalEditor';
|
|
17
16
|
export declare const emptyFunction: () => void;
|
|
18
17
|
export declare function resetRandomKey(): void;
|
|
@@ -27,7 +26,7 @@ export declare function $isTokenOrInertOrSegmented(node: TextNode): boolean;
|
|
|
27
26
|
export declare function $isTokenOrInert(node: TextNode): boolean;
|
|
28
27
|
export declare function getDOMTextNode(element: Node | null): Text | null;
|
|
29
28
|
export declare function toggleTextFormatType(format: number, type: TextFormatType, alignWithFormat: null | number): number;
|
|
30
|
-
export declare function $isLeafNode(node: LexicalNode | null | undefined):
|
|
29
|
+
export declare function $isLeafNode(node: LexicalNode | null | undefined): node is TextNode | LineBreakNode | DecoratorNode<unknown>;
|
|
31
30
|
export declare function $setNodeKey(node: LexicalNode, existingKey: NodeKey | null | undefined): void;
|
|
32
31
|
export declare function removeFromParent(writableNode: LexicalNode): void;
|
|
33
32
|
export declare function internalMarkNodeAsDirty(node: LexicalNode): void;
|
|
@@ -38,7 +37,7 @@ export declare function $getNodeByKey<T extends LexicalNode>(key: NodeKey, _edit
|
|
|
38
37
|
export declare function getNodeFromDOMNode(dom: Node, editorState?: EditorState): LexicalNode | null;
|
|
39
38
|
export declare function $getNearestNodeFromDOMNode(startingDOM: Node, editorState?: EditorState): LexicalNode | null;
|
|
40
39
|
export declare function cloneDecorators(editor: LexicalEditor): Record<NodeKey, unknown>;
|
|
41
|
-
export declare function getEditorStateTextContent(editorState:
|
|
40
|
+
export declare function getEditorStateTextContent(editorState: EditorState): string;
|
|
42
41
|
export declare function markAllNodesAsDirty(editor: LexicalEditor, type: string): void;
|
|
43
42
|
export declare function $getRoot(): RootNode;
|
|
44
43
|
export declare function internalGetRoot(editorState: EditorState): RootNode;
|
|
@@ -82,9 +81,9 @@ export declare function isReturn(keyCode: number): boolean;
|
|
|
82
81
|
export declare function isBackspace(keyCode: number): boolean;
|
|
83
82
|
export declare function isEscape(keyCode: number): boolean;
|
|
84
83
|
export declare function isDelete(keyCode: number): boolean;
|
|
85
|
-
export declare function getCachedClassNameArray
|
|
84
|
+
export declare function getCachedClassNameArray(classNamesTheme: EditorThemeClasses, classNameThemeType: string): Array<string>;
|
|
86
85
|
export declare function setMutatedNode(mutatedNodes: MutatedNodes, registeredNodes: RegisteredNodes, mutationListeners: MutationListeners, node: LexicalNode, mutation: NodeMutation): void;
|
|
87
|
-
export declare function $nodesOfType<T extends LexicalNode>(klass: Klass<T>): Array<
|
|
86
|
+
export declare function $nodesOfType<T extends LexicalNode>(klass: Klass<T>): Array<LexicalNode>;
|
|
88
87
|
export declare function $getDecoratorNode(focus: PointType, isBackward: boolean): null | LexicalNode;
|
|
89
88
|
export declare function isFirefoxClipboardEvents(): boolean;
|
|
90
89
|
export declare function dispatchCommand<P>(editor: LexicalEditor, type: LexicalCommand<P>, payload: P): boolean;
|
package/LexicalVersion.d.ts
CHANGED
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, LexicalCommand, LexicalEditor, NodeMutation, ReadOnlyListener, SerializedEditor, Spread, } from './LexicalEditor';
|
|
8
|
+
export type { CommandListenerPriority, EditorConfig, EditorThemeClasses, IntentionallyMarkedAsDirtyElement, Klass, LexicalCommand, LexicalEditor, 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';
|
|
@@ -66,6 +66,6 @@ export declare class ElementNode extends LexicalNode {
|
|
|
66
66
|
canInsertTextAfter(): boolean;
|
|
67
67
|
isInline(): boolean;
|
|
68
68
|
canMergeWith(node: ElementNode): boolean;
|
|
69
|
-
extractWithChild(child: LexicalNode, selection: RangeSelection | NodeSelection | GridSelection, destination: 'clone' | 'html'): boolean;
|
|
69
|
+
extractWithChild(child: LexicalNode, selection: RangeSelection | NodeSelection | GridSelection | null, destination: 'clone' | 'html'): boolean;
|
|
70
70
|
}
|
|
71
71
|
export declare function $isElementNode(node: LexicalNode | null | undefined): node is ElementNode;
|
|
@@ -18,6 +18,7 @@ export declare type SerializedTextNode = Spread<{
|
|
|
18
18
|
text: string;
|
|
19
19
|
}, SerializedLexicalNode>;
|
|
20
20
|
export declare type TextFormatType = 'bold' | 'underline' | 'strikethrough' | 'italic' | 'code' | 'subscript' | 'superscript';
|
|
21
|
+
export declare type TextDetailType = 'directionless' | 'unmergable';
|
|
21
22
|
export declare type TextModeType = 'normal' | 'token' | 'segmented' | 'inert';
|
|
22
23
|
export declare type TextMark = {
|
|
23
24
|
end: null | number;
|
|
@@ -54,8 +55,8 @@ export declare class TextNode extends LexicalNode {
|
|
|
54
55
|
static importJSON(serializedNode: SerializedTextNode): TextNode;
|
|
55
56
|
exportJSON(): SerializedTextNode;
|
|
56
57
|
selectionTransform(prevSelection: null | RangeSelection | NodeSelection | GridSelection, nextSelection: RangeSelection): void;
|
|
57
|
-
setFormat(format: number): this;
|
|
58
|
-
setDetail(detail: number): this;
|
|
58
|
+
setFormat(format: TextFormatType | number): this;
|
|
59
|
+
setDetail(detail: TextDetailType | number): this;
|
|
59
60
|
setStyle(style: string): this;
|
|
60
61
|
toggleFormat(type: TextFormatType): this;
|
|
61
62
|
toggleDirectionless(): this;
|
package/package.json
CHANGED
|
@@ -9,14 +9,11 @@
|
|
|
9
9
|
"rich-text"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "0.3.
|
|
12
|
+
"version": "0.3.6",
|
|
13
13
|
"main": "Lexical.js",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/facebook/lexical",
|
|
17
17
|
"directory": "packages/lexical"
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"utility-types": "^3.10.0"
|
|
21
18
|
}
|
|
22
19
|
}
|