lexical 0.3.1 → 0.3.4

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.
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { LexicalCommand, MutatedNodes, MutationListeners, NodeMutation, RegisteredNode, RegisteredNodes } from './LexicalEditor';
9
+ import type { EditorState } from './LexicalEditorState';
10
+ import type { LexicalNode, NodeKey } from './LexicalNode';
11
+ import type { GridSelection, NodeSelection, PointType, RangeSelection } from './LexicalSelection';
12
+ import type { RootNode } from './nodes/LexicalRootNode';
13
+ import type { TextFormatType, TextNode } from './nodes/LexicalTextNode';
14
+ import type { Klass } from 'shared/types';
15
+ import { ElementNode } from '.';
16
+ import { LexicalEditor } from './LexicalEditor';
17
+ export declare const emptyFunction: () => void;
18
+ export declare function resetRandomKey(): void;
19
+ export declare function generateRandomKey(): string;
20
+ export declare function getRegisteredNodeOrThrow(editor: LexicalEditor, nodeType: string): RegisteredNode;
21
+ export declare const isArray: (arg: any) => arg is any[];
22
+ export declare const scheduleMicroTask: (fn: () => void) => void;
23
+ export declare function isSelectionWithinEditor(editor: LexicalEditor, anchorDOM: null | Node, focusDOM: null | Node): boolean;
24
+ export declare function getNearestEditorFromDOMNode(node: Node | null): LexicalEditor | null;
25
+ export declare function getTextDirection(text: string): 'ltr' | 'rtl' | null;
26
+ export declare function $isTokenOrInertOrSegmented(node: TextNode): boolean;
27
+ export declare function $isTokenOrInert(node: TextNode): boolean;
28
+ export declare function getDOMTextNode(element: Node | null): Text | null;
29
+ export declare function toggleTextFormatType(format: number, type: TextFormatType, alignWithFormat: null | number): number;
30
+ export declare function $isLeafNode(node: LexicalNode | null | undefined): boolean;
31
+ export declare function $setNodeKey(node: LexicalNode, existingKey: NodeKey | null | undefined): void;
32
+ export declare function removeFromParent(writableNode: LexicalNode): void;
33
+ export declare function internalMarkNodeAsDirty(node: LexicalNode): void;
34
+ export declare function internalMarkSiblingsAsDirty(node: LexicalNode): void;
35
+ export declare function $setCompositionKey(compositionKey: null | NodeKey): void;
36
+ export declare function $getCompositionKey(): null | NodeKey;
37
+ export declare function $getNodeByKey<T extends LexicalNode>(key: NodeKey, _editorState?: EditorState): T | null;
38
+ export declare function getNodeFromDOMNode(dom: Node, editorState?: EditorState): LexicalNode | null;
39
+ export declare function $getNearestNodeFromDOMNode(startingDOM: Node, editorState?: EditorState): LexicalNode | null;
40
+ export declare function cloneDecorators(editor: LexicalEditor): Record<NodeKey, unknown>;
41
+ export declare function getEditorStateTextContent(editorState: any): string;
42
+ export declare function markAllNodesAsDirty(editor: LexicalEditor, type: string): void;
43
+ export declare function $getRoot(): RootNode;
44
+ export declare function internalGetRoot(editorState: EditorState): RootNode;
45
+ export declare function $setSelection(selection: null | RangeSelection | NodeSelection | GridSelection): void;
46
+ export declare function $flushMutations(): void;
47
+ export declare function getNodeFromDOM(dom: Node): null | LexicalNode;
48
+ export declare function getTextNodeOffset(node: TextNode, moveSelectionToEnd: boolean): number;
49
+ export declare function doesContainGrapheme(str: string): boolean;
50
+ export declare function getEditorsToPropagate(editor: LexicalEditor): Array<LexicalEditor>;
51
+ export declare function createUID(): string;
52
+ export declare function $updateSelectedTextFromDOM(editor: LexicalEditor, isCompositionEnd: boolean, data?: string): void;
53
+ export declare function $updateTextNodeFromDOMContent(textNode: TextNode, textContent: string, anchorOffset: null | number, focusOffset: null | number, compositionEnd: boolean): void;
54
+ export declare function $shouldPreventDefaultAndInsertText(selection: RangeSelection, text: string): boolean;
55
+ export declare function isTab(keyCode: number, altKey: boolean, ctrlKey: boolean, metaKey: boolean): boolean;
56
+ export declare function isBold(keyCode: number, altKey: boolean, metaKey: boolean, ctrlKey: boolean): boolean;
57
+ export declare function isItalic(keyCode: number, altKey: boolean, metaKey: boolean, ctrlKey: boolean): boolean;
58
+ export declare function isUnderline(keyCode: number, altKey: boolean, metaKey: boolean, ctrlKey: boolean): boolean;
59
+ export declare function isParagraph(keyCode: number, shiftKey: boolean): boolean;
60
+ export declare function isLineBreak(keyCode: number, shiftKey: boolean): boolean;
61
+ export declare function isOpenLineBreak(keyCode: number, ctrlKey: boolean): boolean;
62
+ export declare function isDeleteWordBackward(keyCode: number, altKey: boolean, ctrlKey: boolean): boolean;
63
+ export declare function isDeleteWordForward(keyCode: number, altKey: boolean, ctrlKey: boolean): boolean;
64
+ export declare function isDeleteLineBackward(keyCode: number, metaKey: boolean): boolean;
65
+ export declare function isDeleteLineForward(keyCode: number, metaKey: boolean): boolean;
66
+ export declare function isDeleteBackward(keyCode: number, altKey: boolean, metaKey: boolean, ctrlKey: boolean): boolean;
67
+ export declare function isDeleteForward(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
68
+ export declare function isUndo(keyCode: number, shiftKey: boolean, metaKey: boolean, ctrlKey: boolean): boolean;
69
+ export declare function isRedo(keyCode: number, shiftKey: boolean, metaKey: boolean, ctrlKey: boolean): boolean;
70
+ export declare function isCopy(keyCode: number, shiftKey: boolean, metaKey: boolean, ctrlKey: boolean): boolean;
71
+ export declare function isCut(keyCode: number, shiftKey: boolean, metaKey: boolean, ctrlKey: boolean): boolean;
72
+ export declare function isMoveBackward(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
73
+ export declare function isMoveToStart(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
74
+ export declare function isMoveForward(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
75
+ export declare function isMoveToEnd(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
76
+ export declare function isMoveUp(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
77
+ export declare function isMoveDown(keyCode: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
78
+ export declare function isModifier(ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
79
+ export declare function isSpace(keyCode: number): boolean;
80
+ export declare function controlOrMeta(metaKey: boolean, ctrlKey: boolean): boolean;
81
+ export declare function isReturn(keyCode: number): boolean;
82
+ export declare function isBackspace(keyCode: number): boolean;
83
+ export declare function isEscape(keyCode: number): boolean;
84
+ export declare function isDelete(keyCode: number): boolean;
85
+ export declare function getCachedClassNameArray<T>(classNamesTheme: T, classNameThemeType: string): Array<string>;
86
+ 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<T>;
88
+ export declare function $getDecoratorNode(focus: PointType, isBackward: boolean): null | LexicalNode;
89
+ export declare function isFirefoxClipboardEvents(): boolean;
90
+ export declare function dispatchCommand<P>(editor: LexicalEditor, type: LexicalCommand<P>, payload: P): boolean;
91
+ export declare function $textContentRequiresDoubleLinebreakAtEnd(node: ElementNode): boolean;
92
+ export declare function getElementByKeyOrThrow(editor: LexicalEditor, key: NodeKey): HTMLElement;
93
+ export declare function scrollIntoViewIfNeeded(editor: LexicalEditor, anchor: PointType, rootElement: HTMLElement, tags: Set<string>): void;
94
+ export declare function $hasUpdateTag(tag: string): boolean;
95
+ export declare function $addUpdateTag(tag: string): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export declare const VERSION = "0.3.4";
package/README.md CHANGED
@@ -37,6 +37,7 @@ An editor instance can be created from the `lexical` package and accepts an opti
37
37
  import {createEditor} from 'lexical';
38
38
 
39
39
  const config = {
40
+ namespace: 'MyEditor',
40
41
  theme: {
41
42
  ...
42
43
  },
package/index.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export type { CommandListenerPriority, EditorConfig, EditorThemeClasses, IntentionallyMarkedAsDirtyElement, LexicalCommand, LexicalEditor, NodeMutation, ReadOnlyListener, SerializedEditor, Spread, } from './LexicalEditor';
9
+ export type { EditorState, SerializedEditorState } from './LexicalEditorState';
10
+ export type { DOMChildConversion, DOMConversion, DOMConversionFn, DOMConversionMap, DOMConversionOutput, DOMExportOutput, LexicalNode, NodeKey, NodeMap, SerializedLexicalNode, } from './LexicalNode';
11
+ export type { BaseSelection, ElementPointType as ElementPoint, GridSelection, GridSelectionShape, NodeSelection, Point, RangeSelection, TextPointType as TextPoint, } from './LexicalSelection';
12
+ export type { ElementFormatType, SerializedElementNode, } from './nodes/LexicalElementNode';
13
+ export type { SerializedGridCellNode } from './nodes/LexicalGridCellNode';
14
+ export type { SerializedRootNode } from './nodes/LexicalRootNode';
15
+ export type { SerializedTextNode, TextFormatType, TextModeType, } from './nodes/LexicalTextNode';
16
+ export { BLUR_COMMAND, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, CLICK_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, COPY_COMMAND, createCommand, CUT_COMMAND, DELETE_CHARACTER_COMMAND, DELETE_LINE_COMMAND, DELETE_WORD_COMMAND, DRAGEND_COMMAND, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, FOCUS_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, INDENT_CONTENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, KEY_SPACE_COMMAND, KEY_TAB_COMMAND, MOVE_TO_END, MOVE_TO_START, OUTDENT_CONTENT_COMMAND, PASTE_COMMAND, REDO_COMMAND, REMOVE_TEXT_COMMAND, SELECTION_CHANGE_COMMAND, UNDO_COMMAND, } from './LexicalCommands';
17
+ export { COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, createEditor, } from './LexicalEditor';
18
+ export type { EventHandler } from './LexicalEvents';
19
+ export { $createGridSelection, $createNodeSelection, $createRangeSelection, $getPreviousSelection, $getSelection, $isGridSelection, $isNodeSelection, $isRangeSelection, } from './LexicalSelection';
20
+ export { $parseSerializedNode } from './LexicalUpdates';
21
+ export { $getDecoratorNode, $getNearestNodeFromDOMNode, $getNodeByKey, $getRoot, $isLeafNode, $nodesOfType, $setCompositionKey, $setSelection, } from './LexicalUtils';
22
+ export { VERSION } from './LexicalVersion';
23
+ export { $isDecoratorNode, DecoratorNode } from './nodes/LexicalDecoratorNode';
24
+ export { $isElementNode, ElementNode } from './nodes/LexicalElementNode';
25
+ export { $isGridCellNode, GridCellNode } from './nodes/LexicalGridCellNode';
26
+ export { $isGridNode, GridNode } from './nodes/LexicalGridNode';
27
+ export { $isGridRowNode, GridRowNode } from './nodes/LexicalGridRowNode';
28
+ export { $createLineBreakNode, $isLineBreakNode, LineBreakNode, } from './nodes/LexicalLineBreakNode';
29
+ export { $createParagraphNode, $isParagraphNode, ParagraphNode, } from './nodes/LexicalParagraphNode';
30
+ export { $isRootNode, RootNode } from './nodes/LexicalRootNode';
31
+ export { $createTextNode, $isTextNode, TextNode } from './nodes/LexicalTextNode';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { LexicalEditor } from '../LexicalEditor';
9
+ import type { NodeKey } from '../LexicalNode';
10
+ import { EditorConfig } from 'lexical';
11
+ import { LexicalNode } from '../LexicalNode';
12
+ export declare class DecoratorNode<T> extends LexicalNode {
13
+ constructor(key?: NodeKey);
14
+ decorate(editor: LexicalEditor, config: EditorConfig): T;
15
+ isIsolated(): boolean;
16
+ isTopLevel(): boolean;
17
+ }
18
+ export declare function $isDecoratorNode<T>(node: LexicalNode | null | undefined): node is DecoratorNode<T>;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { NodeKey, SerializedLexicalNode } from '../LexicalNode';
9
+ import type { GridSelection, NodeSelection, RangeSelection } from '../LexicalSelection';
10
+ import type { Spread } from 'lexical';
11
+ import { TextNode } from '../';
12
+ import { LexicalNode } from '../LexicalNode';
13
+ export declare type SerializedElementNode = Spread<{
14
+ children: Array<SerializedLexicalNode>;
15
+ direction: 'ltr' | 'rtl' | null;
16
+ format: ElementFormatType;
17
+ indent: number;
18
+ }, SerializedLexicalNode>;
19
+ export declare type ElementFormatType = 'left' | 'center' | 'right' | 'justify' | '';
20
+ export declare class ElementNode extends LexicalNode {
21
+ __children: Array<NodeKey>;
22
+ __format: number;
23
+ __indent: number;
24
+ __dir: 'ltr' | 'rtl' | null;
25
+ constructor(key?: NodeKey);
26
+ getFormat(): number;
27
+ getFormatType(): ElementFormatType;
28
+ getIndent(): number;
29
+ getChildren<T extends LexicalNode>(): Array<T>;
30
+ getChildrenKeys(): Array<NodeKey>;
31
+ getChildrenSize(): number;
32
+ isEmpty(): boolean;
33
+ isDirty(): boolean;
34
+ isLastChild(): boolean;
35
+ getAllTextNodes(includeInert?: boolean): Array<TextNode>;
36
+ getFirstDescendant<T extends LexicalNode>(): null | T;
37
+ getLastDescendant<T extends LexicalNode>(): null | T;
38
+ getDescendantByIndex<T extends LexicalNode>(index: number): null | T;
39
+ getFirstChild<T extends LexicalNode>(): null | T;
40
+ getFirstChildOrThrow<T extends LexicalNode>(): T;
41
+ getLastChild<T extends LexicalNode>(): null | T;
42
+ getChildAtIndex<T extends LexicalNode>(index: number): null | T;
43
+ getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
44
+ getDirection(): 'ltr' | 'rtl' | null;
45
+ hasFormat(type: ElementFormatType): boolean;
46
+ select(_anchorOffset?: number, _focusOffset?: number): RangeSelection;
47
+ selectStart(): RangeSelection;
48
+ selectEnd(): RangeSelection;
49
+ clear(): this;
50
+ append(...nodesToAppend: LexicalNode[]): this;
51
+ setDirection(direction: 'ltr' | 'rtl' | null): this;
52
+ setFormat(type: ElementFormatType): this;
53
+ setIndent(indentLevel: number): this;
54
+ splice(start: number, deleteCount: number, nodesToInsert: Array<LexicalNode>): this;
55
+ exportJSON(): SerializedElementNode;
56
+ insertNewAfter(selection: RangeSelection): null | LexicalNode;
57
+ canInsertTab(): boolean;
58
+ canIndent(): boolean;
59
+ collapseAtStart(selection: RangeSelection): boolean;
60
+ excludeFromCopy(destination?: 'clone' | 'html'): boolean;
61
+ canExtractContents(): boolean;
62
+ canReplaceWith(replacement: LexicalNode): boolean;
63
+ canInsertAfter(node: LexicalNode): boolean;
64
+ canBeEmpty(): boolean;
65
+ canInsertTextBefore(): boolean;
66
+ canInsertTextAfter(): boolean;
67
+ isInline(): boolean;
68
+ canMergeWith(node: ElementNode): boolean;
69
+ extractWithChild(child: LexicalNode, selection: RangeSelection | NodeSelection | GridSelection, destination: 'clone' | 'html'): boolean;
70
+ }
71
+ export declare function $isElementNode(node: LexicalNode | null | undefined): node is ElementNode;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { LexicalNode, NodeKey, SerializedElementNode, Spread } from 'lexical';
9
+ import { ElementNode } from './LexicalElementNode';
10
+ export declare type SerializedGridCellNode = Spread<{
11
+ colSpan: number;
12
+ }, SerializedElementNode>;
13
+ export declare class GridCellNode extends ElementNode {
14
+ __colSpan: number;
15
+ constructor(colSpan: number, key?: NodeKey);
16
+ exportJSON(): SerializedGridCellNode;
17
+ }
18
+ export declare function $isGridCellNode(node: GridCellNode | LexicalNode | null | undefined): node is GridCellNode;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { LexicalNode } from '../LexicalNode';
9
+ import { ElementNode } from './LexicalElementNode';
10
+ export declare class GridNode extends ElementNode {
11
+ }
12
+ export declare function $isGridNode(node: LexicalNode | null | undefined): node is GridNode;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { LexicalNode } from '../LexicalNode';
9
+ import { ElementNode } from './LexicalElementNode';
10
+ export declare class GridRowNode extends ElementNode {
11
+ }
12
+ export declare function $isGridRowNode(node: LexicalNode | null | undefined): node is GridRowNode;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { DOMConversionMap, NodeKey, SerializedLexicalNode } from '../LexicalNode';
9
+ import type { Spread } from 'lexical';
10
+ import { LexicalNode } from '../LexicalNode';
11
+ export declare type SerializedLineBreakNode = Spread<{
12
+ type: 'linebreak';
13
+ }, SerializedLexicalNode>;
14
+ export declare class LineBreakNode extends LexicalNode {
15
+ static getType(): string;
16
+ static clone(node: LineBreakNode): LineBreakNode;
17
+ constructor(key?: NodeKey);
18
+ getTextContent(): '\n';
19
+ createDOM(): HTMLElement;
20
+ updateDOM(): false;
21
+ static importDOM(): DOMConversionMap | null;
22
+ static importJSON(serializedLineBreakNode: SerializedLineBreakNode): LineBreakNode;
23
+ exportJSON(): SerializedLexicalNode;
24
+ }
25
+ export declare function $createLineBreakNode(): LineBreakNode;
26
+ export declare function $isLineBreakNode(node: LexicalNode | null | undefined): node is LineBreakNode;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { EditorConfig, LexicalEditor } from '../LexicalEditor';
9
+ import type { DOMConversionMap, DOMExportOutput, LexicalNode } from '../LexicalNode';
10
+ import type { SerializedElementNode } from './LexicalElementNode';
11
+ import type { Spread } from 'lexical';
12
+ import { ElementNode } from './LexicalElementNode';
13
+ export declare type SerializedParagraphNode = Spread<{
14
+ type: 'paragraph';
15
+ version: 1;
16
+ }, SerializedElementNode>;
17
+ export declare class ParagraphNode extends ElementNode {
18
+ static getType(): string;
19
+ static clone(node: ParagraphNode): ParagraphNode;
20
+ createDOM(config: EditorConfig): HTMLElement;
21
+ updateDOM(prevNode: ParagraphNode, dom: HTMLElement): boolean;
22
+ static importDOM(): DOMConversionMap | null;
23
+ exportDOM(editor: LexicalEditor): DOMExportOutput;
24
+ static importJSON(serializedNode: SerializedParagraphNode): ParagraphNode;
25
+ exportJSON(): SerializedElementNode;
26
+ insertNewAfter(): ParagraphNode;
27
+ collapseAtStart(): boolean;
28
+ }
29
+ export declare function $createParagraphNode(): ParagraphNode;
30
+ export declare function $isParagraphNode(node: LexicalNode | null | undefined): node is ParagraphNode;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { LexicalNode } from '../LexicalNode';
9
+ import type { SerializedElementNode } from './LexicalElementNode';
10
+ import { ElementNode } from './LexicalElementNode';
11
+ export declare type SerializedRootNode = SerializedElementNode;
12
+ export declare class RootNode extends ElementNode {
13
+ __cachedText: null | string;
14
+ static getType(): string;
15
+ static clone(): RootNode;
16
+ constructor();
17
+ getTopLevelElementOrThrow(): never;
18
+ getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
19
+ remove(): never;
20
+ replace<N = LexicalNode>(node: N): never;
21
+ insertBefore(nodeToInsert: LexicalNode): LexicalNode;
22
+ insertAfter(nodeToInsert: LexicalNode): LexicalNode;
23
+ updateDOM(prevNode: RootNode, dom: HTMLElement): false;
24
+ append(...nodesToAppend: LexicalNode[]): this;
25
+ static importJSON(serializedNode: SerializedRootNode): RootNode;
26
+ exportJSON(): SerializedRootNode;
27
+ }
28
+ export declare function $createRootNode(): RootNode;
29
+ export declare function $isRootNode(node: RootNode | LexicalNode | null | undefined): node is RootNode;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type { EditorConfig } from '../LexicalEditor';
9
+ import type { DOMConversionMap, NodeKey, SerializedLexicalNode } from '../LexicalNode';
10
+ import type { GridSelection, NodeSelection, RangeSelection } from '../LexicalSelection';
11
+ import type { Spread } from 'lexical';
12
+ import { LexicalNode } from '../LexicalNode';
13
+ export declare type SerializedTextNode = Spread<{
14
+ detail: number;
15
+ format: number;
16
+ mode: TextModeType;
17
+ style: string;
18
+ text: string;
19
+ }, SerializedLexicalNode>;
20
+ export declare type TextFormatType = 'bold' | 'underline' | 'strikethrough' | 'italic' | 'code' | 'subscript' | 'superscript';
21
+ export declare type TextModeType = 'normal' | 'token' | 'segmented' | 'inert';
22
+ export declare type TextMark = {
23
+ end: null | number;
24
+ id: string;
25
+ start: null | number;
26
+ };
27
+ export declare type TextMarks = Array<TextMark>;
28
+ export declare class TextNode extends LexicalNode {
29
+ __text: string;
30
+ __format: number;
31
+ __style: string;
32
+ __mode: 0 | 1 | 2 | 3;
33
+ __detail: number;
34
+ static getType(): string;
35
+ static clone(node: TextNode): TextNode;
36
+ constructor(text: string, key?: NodeKey);
37
+ getFormat(): number;
38
+ getDetail(): number;
39
+ getMode(): TextModeType;
40
+ getStyle(): string;
41
+ isToken(): boolean;
42
+ isComposing(): boolean;
43
+ isSegmented(): boolean;
44
+ isInert(): boolean;
45
+ isDirectionless(): boolean;
46
+ isUnmergeable(): boolean;
47
+ hasFormat(type: TextFormatType): boolean;
48
+ isSimpleText(): boolean;
49
+ getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
50
+ getFormatFlags(type: TextFormatType, alignWithFormat: null | number): number;
51
+ createDOM(config: EditorConfig): HTMLElement;
52
+ updateDOM(prevNode: TextNode, dom: HTMLElement, config: EditorConfig): boolean;
53
+ static importDOM(): DOMConversionMap | null;
54
+ static importJSON(serializedNode: SerializedTextNode): TextNode;
55
+ exportJSON(): SerializedTextNode;
56
+ selectionTransform(prevSelection: null | RangeSelection | NodeSelection | GridSelection, nextSelection: RangeSelection): void;
57
+ setFormat(format: number): this;
58
+ setDetail(detail: number): this;
59
+ setStyle(style: string): this;
60
+ toggleFormat(type: TextFormatType): this;
61
+ toggleDirectionless(): this;
62
+ toggleUnmergeable(): this;
63
+ setMode(type: TextModeType): this;
64
+ setTextContent(text: string): this;
65
+ select(_anchorOffset?: number, _focusOffset?: number): RangeSelection;
66
+ spliceText(offset: number, delCount: number, newText: string, moveSelection?: boolean): TextNode;
67
+ canInsertTextBefore(): boolean;
68
+ canInsertTextAfter(): boolean;
69
+ splitText(...splitOffsets: Array<number>): Array<TextNode>;
70
+ mergeWithSibling(target: TextNode): TextNode;
71
+ isTextEntity(): boolean;
72
+ }
73
+ export declare function $createTextNode(text?: string): TextNode;
74
+ export declare function $isTextNode(node: LexicalNode | null | undefined): node is TextNode;
package/package.json CHANGED
@@ -9,12 +9,14 @@
9
9
  "rich-text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.3.1",
12
+ "version": "0.3.4",
13
13
  "main": "Lexical.js",
14
- "typings": "Lexical.d.ts",
15
14
  "repository": {
16
15
  "type": "git",
17
16
  "url": "https://github.com/facebook/lexical",
18
17
  "directory": "packages/lexical"
18
+ },
19
+ "devDependencies": {
20
+ "utility-types": "^3.10.0"
19
21
  }
20
22
  }