lexical 0.2.4 → 0.2.5
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 +29 -44
- package/Lexical.dev.js +582 -140
- package/Lexical.js.flow +27 -44
- package/Lexical.prod.js +164 -157
- package/package.json +1 -1
package/Lexical.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export var OUTDENT_CONTENT_COMMAND: LexicalCommand<void>;
|
|
|
42
42
|
export var DROP_COMMAND: LexicalCommand<DragEvent>;
|
|
43
43
|
export var FORMAT_ELEMENT_COMMAND: LexicalCommand<ElementFormatType>;
|
|
44
44
|
export var DRAGSTART_COMMAND: LexicalCommand<DragEvent>;
|
|
45
|
+
export var DRAGEND_COMMAND: LexicalCommand<DragEvent>;
|
|
45
46
|
export var COPY_COMMAND: LexicalCommand<ClipboardEvent>;
|
|
46
47
|
export var CUT_COMMAND: LexicalCommand<ClipboardEvent>;
|
|
47
48
|
export var CLEAR_EDITOR_COMMAND: LexicalCommand<void>;
|
|
@@ -116,7 +117,7 @@ export declare class LexicalEditor {
|
|
|
116
117
|
_onError: ErrorHandler;
|
|
117
118
|
_decorators: Record<NodeKey, unknown>;
|
|
118
119
|
_pendingDecorators: null | Record<NodeKey, unknown>;
|
|
119
|
-
_config: EditorConfig
|
|
120
|
+
_config: EditorConfig;
|
|
120
121
|
_dirtyType: 0 | 1 | 2;
|
|
121
122
|
_cloneNotNeeded: Set<NodeKey>;
|
|
122
123
|
_dirtyLeaves: Set<NodeKey>;
|
|
@@ -185,7 +186,6 @@ export type EditorThemeClasses = {
|
|
|
185
186
|
text?: TextNodeThemeClasses;
|
|
186
187
|
paragraph?: EditorThemeClassName;
|
|
187
188
|
image?: EditorThemeClassName;
|
|
188
|
-
//@ts-expect-error
|
|
189
189
|
list?: {
|
|
190
190
|
ul?: EditorThemeClassName;
|
|
191
191
|
ulDepth?: Array<EditorThemeClassName>;
|
|
@@ -214,12 +214,18 @@ export type EditorThemeClasses = {
|
|
|
214
214
|
h5?: EditorThemeClassName;
|
|
215
215
|
};
|
|
216
216
|
// Handle other generic values
|
|
217
|
-
[key: string]:
|
|
217
|
+
[key: string]:
|
|
218
|
+
| EditorThemeClassName
|
|
219
|
+
| Record<
|
|
220
|
+
string,
|
|
221
|
+
| EditorThemeClassName
|
|
222
|
+
| Array<EditorThemeClassName>
|
|
223
|
+
| Record<string, EditorThemeClassName>
|
|
224
|
+
>;
|
|
218
225
|
};
|
|
219
|
-
export type EditorConfig
|
|
226
|
+
export type EditorConfig = {
|
|
220
227
|
namespace: string;
|
|
221
228
|
theme: EditorThemeClasses;
|
|
222
|
-
context: EditorContext;
|
|
223
229
|
disableEvents?: boolean;
|
|
224
230
|
};
|
|
225
231
|
export type CommandListenerPriority = 0 | 1 | 2 | 3 | 4;
|
|
@@ -229,11 +235,10 @@ export const COMMAND_PRIORITY_NORMAL = 2;
|
|
|
229
235
|
export const COMMAND_PRIORITY_HIGH = 3;
|
|
230
236
|
export const COMMAND_PRIORITY_CRITICAL = 4;
|
|
231
237
|
export type IntentionallyMarkedAsDirtyElement = boolean;
|
|
232
|
-
export function createEditor
|
|
238
|
+
export function createEditor(editorConfig?: {
|
|
233
239
|
namespace?: string;
|
|
234
240
|
editorState?: EditorState;
|
|
235
241
|
theme?: EditorThemeClasses;
|
|
236
|
-
context?: EditorContext;
|
|
237
242
|
parentEditor?: LexicalEditor;
|
|
238
243
|
nodes?: Array<Class<LexicalNode>>;
|
|
239
244
|
onError: (error: Error) => void;
|
|
@@ -350,17 +355,8 @@ export declare class LexicalNode {
|
|
|
350
355
|
includeDirectionless?: false,
|
|
351
356
|
): number;
|
|
352
357
|
exportDOM(editor: LexicalEditor): DOMExportOutput;
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
config: EditorConfig<EditorContext>,
|
|
356
|
-
editor: LexicalEditor,
|
|
357
|
-
): HTMLElement;
|
|
358
|
-
// $FlowFixMe
|
|
359
|
-
updateDOM<EditorContext extends Record<string, any>>( // $FlowFixMe
|
|
360
|
-
prevNode: any,
|
|
361
|
-
dom: HTMLElement,
|
|
362
|
-
config: EditorConfig<EditorContext>,
|
|
363
|
-
): boolean;
|
|
358
|
+
createDOM(config: EditorConfig, editor: LexicalEditor): HTMLElement;
|
|
359
|
+
updateDOM(prevNode: any, dom: HTMLElement, config: EditorConfig): boolean;
|
|
364
360
|
remove(preserveEmptyParent?: boolean): void;
|
|
365
361
|
replace<N extends LexicalNode>(replaceWith: N): N;
|
|
366
362
|
insertAfter(nodeToInsert: LexicalNode): LexicalNode;
|
|
@@ -417,15 +413,14 @@ export type GridSelectionShape = {
|
|
|
417
413
|
};
|
|
418
414
|
export declare class GridSelection {
|
|
419
415
|
gridKey: NodeKey;
|
|
420
|
-
anchorCellKey: NodeKey;
|
|
421
416
|
anchor: PointType;
|
|
422
|
-
focusCellKey: NodeKey;
|
|
423
417
|
focus: PointType;
|
|
424
418
|
dirty: boolean;
|
|
425
|
-
constructor(gridKey: NodeKey,
|
|
419
|
+
constructor(gridKey: NodeKey, anchor: PointType, focus: PointType);
|
|
426
420
|
is(selection: null | RangeSelection | NodeSelection | GridSelection): boolean;
|
|
427
421
|
set(gridKey: NodeKey, anchorCellKey: NodeKey, focusCellKey: NodeKey): void;
|
|
428
422
|
clone(): GridSelection;
|
|
423
|
+
getCharacterOffsets(): [number, number];
|
|
429
424
|
extract(): Array<LexicalNode>;
|
|
430
425
|
isCollapsed(): boolean;
|
|
431
426
|
isBackward(): boolean;
|
|
@@ -486,6 +481,7 @@ export declare class RangeSelection {
|
|
|
486
481
|
insertNodes(nodes: Array<LexicalNode>, selectStart?: boolean): boolean;
|
|
487
482
|
insertParagraph(): void;
|
|
488
483
|
insertLineBreak(selectStart?: boolean): void;
|
|
484
|
+
getCharacterOffsets(): [number, number];
|
|
489
485
|
extract(): Array<LexicalNode>;
|
|
490
486
|
modify(
|
|
491
487
|
alter: 'move' | 'extend',
|
|
@@ -517,7 +513,6 @@ type ElementPointType = {
|
|
|
517
513
|
isBefore: (arg0: PointType) => boolean;
|
|
518
514
|
getNode: () => ElementNode;
|
|
519
515
|
set: (key: NodeKey, offset: number, type: 'text' | 'element') => void;
|
|
520
|
-
getCharacterOffset: () => number;
|
|
521
516
|
isAtNodeEnd: () => boolean;
|
|
522
517
|
};
|
|
523
518
|
export type Point = PointType;
|
|
@@ -530,7 +525,6 @@ declare class _Point {
|
|
|
530
525
|
constructor(key: NodeKey, offset: number, type: 'text' | 'element');
|
|
531
526
|
is(point: PointType): boolean;
|
|
532
527
|
isBefore(b: PointType): boolean;
|
|
533
|
-
getCharacterOffset(): number;
|
|
534
528
|
getNode(): LexicalNode;
|
|
535
529
|
set(key: NodeKey, offset: number, type: 'text' | 'element'): void;
|
|
536
530
|
}
|
|
@@ -564,15 +558,22 @@ export type TextFormatType =
|
|
|
564
558
|
| 'subscript'
|
|
565
559
|
| 'superscript';
|
|
566
560
|
type TextModeType = 'normal' | 'token' | 'segmented' | 'inert';
|
|
561
|
+
export type TextMark = {end: null | number; id: string; start: null | number};
|
|
562
|
+
|
|
563
|
+
export type TextMarks = Array<TextMark>;
|
|
567
564
|
export declare class TextNode extends LexicalNode {
|
|
568
565
|
__text: string;
|
|
569
566
|
__format: number;
|
|
570
567
|
__style: string;
|
|
571
568
|
__mode: 0 | 1 | 2 | 3;
|
|
572
569
|
__detail: number;
|
|
570
|
+
__marks: null | TextMarks;
|
|
573
571
|
static getType(): string;
|
|
574
572
|
static clone(node: any): TextNode;
|
|
575
573
|
constructor(text: string, key?: NodeKey);
|
|
574
|
+
getMark(id: string): null | TextMark;
|
|
575
|
+
setMark(id: string, start: null | number, end: null | number): void;
|
|
576
|
+
deleteMark(id: string): void;
|
|
576
577
|
getFormat(): number;
|
|
577
578
|
getStyle(): string;
|
|
578
579
|
isToken(): boolean;
|
|
@@ -585,14 +586,12 @@ export declare class TextNode extends LexicalNode {
|
|
|
585
586
|
getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
|
|
586
587
|
getFormatFlags(type: TextFormatType, alignWithFormat: null | number): number;
|
|
587
588
|
// $FlowFixMe
|
|
588
|
-
createDOM
|
|
589
|
-
config: EditorConfig<EditorContext>,
|
|
590
|
-
): HTMLElement;
|
|
589
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
591
590
|
// $FlowFixMe
|
|
592
|
-
updateDOM
|
|
591
|
+
updateDOM(
|
|
593
592
|
prevNode: TextNode,
|
|
594
593
|
dom: HTMLElement,
|
|
595
|
-
config: EditorConfig
|
|
594
|
+
config: EditorConfig,
|
|
596
595
|
): boolean;
|
|
597
596
|
selectionTransform(
|
|
598
597
|
prevSelection: null | RangeSelection | NodeSelection | GridSelection,
|
|
@@ -698,6 +697,7 @@ export declare class ElementNode extends LexicalNode {
|
|
|
698
697
|
setIndent(indentLevel: number): ElementNode;
|
|
699
698
|
insertNewAfter(selection: RangeSelection): null | LexicalNode;
|
|
700
699
|
canInsertTab(): boolean;
|
|
700
|
+
canIndent(): boolean;
|
|
701
701
|
collapseAtStart(selection: RangeSelection): boolean;
|
|
702
702
|
excludeFromCopy(): boolean;
|
|
703
703
|
canExtractContents(): boolean;
|
|
@@ -731,21 +731,6 @@ export function $isDecoratorNode(
|
|
|
731
731
|
node: LexicalNode | null | undefined,
|
|
732
732
|
): node is DecoratorNode<unknown>;
|
|
733
733
|
|
|
734
|
-
/**
|
|
735
|
-
* LexicalHorizontalRuleNode
|
|
736
|
-
*/
|
|
737
|
-
export declare class HorizontalRuleNode extends LexicalNode {
|
|
738
|
-
static getType(): string;
|
|
739
|
-
static clone(node: HorizontalRuleNode): HorizontalRuleNode;
|
|
740
|
-
constructor(key?: NodeKey);
|
|
741
|
-
createDOM(): HTMLElement;
|
|
742
|
-
updateDOM(): false;
|
|
743
|
-
}
|
|
744
|
-
export function $createHorizontalRuleNode(): HorizontalRuleNode;
|
|
745
|
-
export function $isHorizontalRuleNode(
|
|
746
|
-
node: LexicalNode | null | undefined,
|
|
747
|
-
): boolean;
|
|
748
|
-
|
|
749
734
|
/**
|
|
750
735
|
* LexicalParagraphNode
|
|
751
736
|
*/
|
|
@@ -753,7 +738,7 @@ export declare class ParagraphNode extends ElementNode {
|
|
|
753
738
|
getType(): string;
|
|
754
739
|
clone(node: ParagraphNode): ParagraphNode;
|
|
755
740
|
constructor(key?: NodeKey);
|
|
756
|
-
createDOM
|
|
741
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
757
742
|
updateDOM(prevNode: ParagraphNode, dom: HTMLElement): boolean;
|
|
758
743
|
insertNewAfter(): ParagraphNode;
|
|
759
744
|
collapseAtStart(): boolean;
|