lexical 0.2.4 → 0.2.7
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 +48 -54
- package/Lexical.dev.js +611 -244
- package/Lexical.js.flow +39 -49
- package/Lexical.prod.js +164 -159
- package/package.json +1 -1
package/Lexical.js.flow
CHANGED
|
@@ -31,6 +31,7 @@ declare export var KEY_ARROW_LEFT_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
|
31
31
|
declare export var KEY_ARROW_UP_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
32
32
|
declare export var KEY_ARROW_DOWN_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
33
33
|
declare export var KEY_ENTER_COMMAND: LexicalCommand<KeyboardEvent | null>;
|
|
34
|
+
declare export var KEY_SPACE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
34
35
|
declare export var KEY_BACKSPACE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
35
36
|
declare export var KEY_ESCAPE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
36
37
|
declare export var KEY_DELETE_COMMAND: LexicalCommand<KeyboardEvent>;
|
|
@@ -41,6 +42,7 @@ declare export var OUTDENT_CONTENT_COMMAND: LexicalCommand<void>;
|
|
|
41
42
|
declare export var DROP_COMMAND: LexicalCommand<DragEvent>;
|
|
42
43
|
declare export var FORMAT_ELEMENT_COMMAND: LexicalCommand<ElementFormatType>;
|
|
43
44
|
declare export var DRAGSTART_COMMAND: LexicalCommand<DragEvent>;
|
|
45
|
+
declare export var DRAGEND_COMMAND: LexicalCommand<DragEvent>;
|
|
44
46
|
declare export var COPY_COMMAND: LexicalCommand<ClipboardEvent>;
|
|
45
47
|
declare export var CUT_COMMAND: LexicalCommand<ClipboardEvent>;
|
|
46
48
|
declare export var CLEAR_EDITOR_COMMAND: LexicalCommand<void>;
|
|
@@ -120,7 +122,7 @@ declare export class LexicalEditor {
|
|
|
120
122
|
_pendingDecorators: null | {
|
|
121
123
|
[NodeKey]: mixed,
|
|
122
124
|
};
|
|
123
|
-
_config: EditorConfig
|
|
125
|
+
_config: EditorConfig;
|
|
124
126
|
_dirtyType: 0 | 1 | 2;
|
|
125
127
|
_cloneNotNeeded: Set<NodeKey>;
|
|
126
128
|
_dirtyLeaves: Set<NodeKey>;
|
|
@@ -130,6 +132,7 @@ declare export class LexicalEditor {
|
|
|
130
132
|
_observer: null | MutationObserver;
|
|
131
133
|
_key: string;
|
|
132
134
|
_readOnly: boolean;
|
|
135
|
+
_headless: boolean;
|
|
133
136
|
isComposing(): boolean;
|
|
134
137
|
registerUpdateListener(listener: UpdateListener): () => void;
|
|
135
138
|
registerRootListener(listener: RootListener): () => void;
|
|
@@ -149,7 +152,7 @@ declare export class LexicalEditor {
|
|
|
149
152
|
klass: Class<T>,
|
|
150
153
|
listener: Transform<T>,
|
|
151
154
|
): () => void;
|
|
152
|
-
dispatchCommand<P>(command: LexicalCommand<P>, payload
|
|
155
|
+
dispatchCommand<P>(command: LexicalCommand<P>, payload: P): boolean;
|
|
153
156
|
hasNodes(nodes: Array<Class<LexicalNode>>): boolean;
|
|
154
157
|
getKey(): string;
|
|
155
158
|
getDecorators<X>(): {
|
|
@@ -160,7 +163,9 @@ declare export class LexicalEditor {
|
|
|
160
163
|
getElementByKey(key: NodeKey): null | HTMLElement;
|
|
161
164
|
getEditorState(): EditorState;
|
|
162
165
|
setEditorState(editorState: EditorState, options?: EditorSetOptions): void;
|
|
163
|
-
parseEditorState(
|
|
166
|
+
parseEditorState(
|
|
167
|
+
maybeStringifiedEditorState: string | ParsedEditorState,
|
|
168
|
+
): EditorState;
|
|
164
169
|
update(updateFn: () => void, options?: EditorUpdateOptions): boolean;
|
|
165
170
|
focus(callbackFn?: () => void): void;
|
|
166
171
|
blur(): void;
|
|
@@ -184,11 +189,12 @@ type TextNodeThemeClasses = {
|
|
|
184
189
|
underlineStrikethrough?: EditorThemeClassName,
|
|
185
190
|
italic?: EditorThemeClassName,
|
|
186
191
|
code?: EditorThemeClassName,
|
|
192
|
+
subscript?: EditorThemeClassName,
|
|
193
|
+
superscript?: EditorThemeClassName,
|
|
187
194
|
};
|
|
188
195
|
export type EditorThemeClasses = {
|
|
189
196
|
ltr?: EditorThemeClassName,
|
|
190
197
|
rtl?: EditorThemeClassName,
|
|
191
|
-
root?: EditorThemeClassName,
|
|
192
198
|
text?: TextNodeThemeClasses,
|
|
193
199
|
paragraph?: EditorThemeClassName,
|
|
194
200
|
image?: EditorThemeClassName,
|
|
@@ -198,6 +204,8 @@ export type EditorThemeClasses = {
|
|
|
198
204
|
ol?: EditorThemeClassName,
|
|
199
205
|
olDepth?: Array<EditorThemeClassName>,
|
|
200
206
|
listitem?: EditorThemeClassName,
|
|
207
|
+
listitemChecked?: EditorThemeClassName,
|
|
208
|
+
listitemUnchecked?: EditorThemeClassName,
|
|
201
209
|
nested?: {
|
|
202
210
|
list?: EditorThemeClassName,
|
|
203
211
|
listitem?: EditorThemeClassName,
|
|
@@ -207,6 +215,8 @@ export type EditorThemeClasses = {
|
|
|
207
215
|
tableRow?: EditorThemeClassName,
|
|
208
216
|
tableCell?: EditorThemeClassName,
|
|
209
217
|
tableCellHeader?: EditorThemeClassName,
|
|
218
|
+
mark?: EditorThemeClassName,
|
|
219
|
+
markOverlap?: EditorThemeClassName,
|
|
210
220
|
link?: EditorThemeClassName,
|
|
211
221
|
quote?: EditorThemeClassName,
|
|
212
222
|
code?: EditorThemeClassName,
|
|
@@ -222,10 +232,9 @@ export type EditorThemeClasses = {
|
|
|
222
232
|
// Handle other generic values
|
|
223
233
|
[string]: EditorThemeClassName | {[string]: EditorThemeClassName},
|
|
224
234
|
};
|
|
225
|
-
export type EditorConfig
|
|
235
|
+
export type EditorConfig = {
|
|
226
236
|
namespace: string,
|
|
227
237
|
theme: EditorThemeClasses,
|
|
228
|
-
context: EditorContext,
|
|
229
238
|
disableEvents?: boolean,
|
|
230
239
|
};
|
|
231
240
|
export type CommandListenerPriority = 0 | 1 | 2 | 3 | 4;
|
|
@@ -236,11 +245,10 @@ export const COMMAND_PRIORITY_HIGH = 3;
|
|
|
236
245
|
export const COMMAND_PRIORITY_CRITICAL = 4;
|
|
237
246
|
|
|
238
247
|
export type IntentionallyMarkedAsDirtyElement = boolean;
|
|
239
|
-
declare export function createEditor
|
|
248
|
+
declare export function createEditor(editorConfig?: {
|
|
240
249
|
namespace?: string,
|
|
241
250
|
editorState?: EditorState,
|
|
242
251
|
theme?: EditorThemeClasses,
|
|
243
|
-
context?: EditorContext,
|
|
244
252
|
parentEditor?: LexicalEditor,
|
|
245
253
|
nodes?: $ReadOnlyArray<Class<LexicalNode>>,
|
|
246
254
|
onError: (error: Error) => void,
|
|
@@ -348,7 +356,6 @@ declare export class LexicalNode {
|
|
|
348
356
|
isParentOf(targetNode: LexicalNode): boolean;
|
|
349
357
|
getNodesBetween(targetNode: LexicalNode): Array<LexicalNode>;
|
|
350
358
|
isDirty(): boolean;
|
|
351
|
-
isComposing(): boolean;
|
|
352
359
|
// $FlowFixMe
|
|
353
360
|
getLatest<T: LexicalNode>(this: T): T;
|
|
354
361
|
// $FlowFixMe
|
|
@@ -358,17 +365,12 @@ declare export class LexicalNode {
|
|
|
358
365
|
includeInert?: boolean,
|
|
359
366
|
includeDirectionless?: false,
|
|
360
367
|
): number;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
config: EditorConfig<EditorContext>,
|
|
364
|
-
editor: LexicalEditor,
|
|
365
|
-
): HTMLElement;
|
|
366
|
-
// $FlowFixMe
|
|
367
|
-
updateDOM<EditorContext: Object>(
|
|
368
|
+
createDOM(config: EditorConfig, editor: LexicalEditor): HTMLElement;
|
|
369
|
+
updateDOM(
|
|
368
370
|
// $FlowFixMe
|
|
369
371
|
prevNode: any,
|
|
370
372
|
dom: HTMLElement,
|
|
371
|
-
config: EditorConfig
|
|
373
|
+
config: EditorConfig,
|
|
372
374
|
): boolean;
|
|
373
375
|
remove(preserveEmptyParent?: boolean): void;
|
|
374
376
|
replace<N: LexicalNode>(replaceWith: N): N;
|
|
@@ -429,19 +431,14 @@ export type GridSelectionShape = {
|
|
|
429
431
|
};
|
|
430
432
|
declare export class GridSelection implements BaseSelection {
|
|
431
433
|
gridKey: NodeKey;
|
|
432
|
-
anchorCellKey: NodeKey;
|
|
433
434
|
anchor: PointType;
|
|
434
|
-
focusCellKey: NodeKey;
|
|
435
435
|
focus: PointType;
|
|
436
436
|
dirty: boolean;
|
|
437
|
-
constructor(
|
|
438
|
-
gridKey: NodeKey,
|
|
439
|
-
anchorCellKey: NodeKey,
|
|
440
|
-
focusCellKey: NodeKey,
|
|
441
|
-
): void;
|
|
437
|
+
constructor(gridKey: NodeKey, anchor: PointType, focus: PointType): void;
|
|
442
438
|
is(selection: null | RangeSelection | NodeSelection | GridSelection): boolean;
|
|
443
439
|
set(gridKey: NodeKey, anchorCellKey: NodeKey, focusCellKey: NodeKey): void;
|
|
444
440
|
clone(): GridSelection;
|
|
441
|
+
getCharacterOffsets(): [number, number];
|
|
445
442
|
extract(): Array<LexicalNode>;
|
|
446
443
|
insertRawText(): void;
|
|
447
444
|
insertText(): void;
|
|
@@ -518,6 +515,7 @@ declare export class RangeSelection implements BaseSelection {
|
|
|
518
515
|
insertNodes(nodes: Array<LexicalNode>, selectStart?: boolean): boolean;
|
|
519
516
|
insertParagraph(): void;
|
|
520
517
|
insertLineBreak(selectStart?: boolean): void;
|
|
518
|
+
getCharacterOffsets(): [number, number];
|
|
521
519
|
extract(): Array<LexicalNode>;
|
|
522
520
|
modify(
|
|
523
521
|
alter: 'move' | 'extend',
|
|
@@ -549,7 +547,6 @@ type ElementPointType = {
|
|
|
549
547
|
isBefore: (PointType) => boolean,
|
|
550
548
|
getNode: () => ElementNode,
|
|
551
549
|
set: (key: NodeKey, offset: number, type: 'text' | 'element') => void,
|
|
552
|
-
getCharacterOffset: () => number,
|
|
553
550
|
isAtNodeEnd: () => boolean,
|
|
554
551
|
};
|
|
555
552
|
export type Point = PointType;
|
|
@@ -561,7 +558,6 @@ declare class _Point {
|
|
|
561
558
|
constructor(key: NodeKey, offset: number, type: 'text' | 'element'): void;
|
|
562
559
|
is(point: PointType): boolean;
|
|
563
560
|
isBefore(b: PointType): boolean;
|
|
564
|
-
getCharacterOffset(): number;
|
|
565
561
|
getNode(): LexicalNode;
|
|
566
562
|
set(key: NodeKey, offset: number, type: 'text' | 'element'): void;
|
|
567
563
|
}
|
|
@@ -608,6 +604,7 @@ declare export class TextNode extends LexicalNode {
|
|
|
608
604
|
constructor(text: string, key?: NodeKey): void;
|
|
609
605
|
getFormat(): number;
|
|
610
606
|
getStyle(): string;
|
|
607
|
+
isComposing(): boolean;
|
|
611
608
|
isToken(): boolean;
|
|
612
609
|
isSegmented(): boolean;
|
|
613
610
|
isInert(): boolean;
|
|
@@ -617,15 +614,11 @@ declare export class TextNode extends LexicalNode {
|
|
|
617
614
|
isSimpleText(): boolean;
|
|
618
615
|
getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
|
|
619
616
|
getFormatFlags(type: TextFormatType, alignWithFormat: null | number): number;
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
config: EditorConfig<EditorContext>,
|
|
623
|
-
): HTMLElement;
|
|
624
|
-
// $FlowFixMe
|
|
625
|
-
updateDOM<EditorContext: Object>(
|
|
617
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
618
|
+
updateDOM(
|
|
626
619
|
prevNode: TextNode,
|
|
627
620
|
dom: HTMLElement,
|
|
628
|
-
config: EditorConfig
|
|
621
|
+
config: EditorConfig,
|
|
629
622
|
): boolean;
|
|
630
623
|
selectionTransform(
|
|
631
624
|
prevSelection: null | RangeSelection | NodeSelection | GridSelection,
|
|
@@ -734,11 +727,17 @@ declare export class ElementNode extends LexicalNode {
|
|
|
734
727
|
setIndent(indentLevel: number): this;
|
|
735
728
|
insertNewAfter(selection: RangeSelection): null | LexicalNode;
|
|
736
729
|
canInsertTab(): boolean;
|
|
730
|
+
canIndent(): boolean;
|
|
737
731
|
collapseAtStart(selection: RangeSelection): boolean;
|
|
738
|
-
excludeFromCopy(): boolean;
|
|
732
|
+
excludeFromCopy(destination: 'clone' | 'html'): boolean;
|
|
739
733
|
canExtractContents(): boolean;
|
|
740
734
|
canReplaceWith(replacement: LexicalNode): boolean;
|
|
741
735
|
canInsertAfter(node: LexicalNode): boolean;
|
|
736
|
+
extractWithChild(
|
|
737
|
+
child: LexicalNode,
|
|
738
|
+
selection: RangeSelection | NodeSelection | GridSelection,
|
|
739
|
+
destination: 'clone' | 'html',
|
|
740
|
+
): boolean;
|
|
742
741
|
canBeEmpty(): boolean;
|
|
743
742
|
canInsertTextBefore(): boolean;
|
|
744
743
|
canInsertTextAfter(): boolean;
|
|
@@ -768,19 +767,6 @@ declare export function $isDecoratorNode(
|
|
|
768
767
|
node: ?LexicalNode,
|
|
769
768
|
): boolean %checks(node instanceof DecoratorNode);
|
|
770
769
|
|
|
771
|
-
/**
|
|
772
|
-
* LexicalHorizontalRuleNode
|
|
773
|
-
*/
|
|
774
|
-
declare export class HorizontalRuleNode extends LexicalNode {
|
|
775
|
-
static getType(): string;
|
|
776
|
-
static clone(node: HorizontalRuleNode): HorizontalRuleNode;
|
|
777
|
-
constructor(key?: NodeKey): void;
|
|
778
|
-
createDOM(): HTMLElement;
|
|
779
|
-
updateDOM(): false;
|
|
780
|
-
}
|
|
781
|
-
declare export function $createHorizontalRuleNode(): HorizontalRuleNode;
|
|
782
|
-
declare export function $isHorizontalRuleNode(node: ?LexicalNode): boolean;
|
|
783
|
-
|
|
784
770
|
/**
|
|
785
771
|
* LexicalParagraphNode
|
|
786
772
|
*/
|
|
@@ -788,7 +774,7 @@ declare export class ParagraphNode extends ElementNode {
|
|
|
788
774
|
static getType(): string;
|
|
789
775
|
static clone(node: ParagraphNode): ParagraphNode;
|
|
790
776
|
constructor(key?: NodeKey): void;
|
|
791
|
-
createDOM
|
|
777
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
792
778
|
updateDOM(prevNode: ParagraphNode, dom: HTMLElement): boolean;
|
|
793
779
|
insertNewAfter(): ParagraphNode;
|
|
794
780
|
collapseAtStart(): boolean;
|
|
@@ -828,7 +814,11 @@ declare export function $getNearestNodeFromDOMNode(
|
|
|
828
814
|
): LexicalNode | null;
|
|
829
815
|
declare export function $getNodeByKey<N: LexicalNode>(key: NodeKey): N | null;
|
|
830
816
|
declare export function $getRoot(): RootNode;
|
|
831
|
-
declare export function $isLeafNode(
|
|
817
|
+
declare export function $isLeafNode(
|
|
818
|
+
node: ?LexicalNode,
|
|
819
|
+
): boolean %checks(node instanceof TextNode ||
|
|
820
|
+
node instanceof LineBreakNode ||
|
|
821
|
+
node instanceof DecoratorNode);
|
|
832
822
|
declare export function $setCompositionKey(
|
|
833
823
|
compositionKey: null | NodeKey,
|
|
834
824
|
): void;
|