lexical 0.4.0 → 0.5.0

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.
@@ -13,7 +13,7 @@ export declare const DELETE_CHARACTER_COMMAND: LexicalCommand<boolean>;
13
13
  export declare const INSERT_LINE_BREAK_COMMAND: LexicalCommand<boolean>;
14
14
  export declare const INSERT_PARAGRAPH_COMMAND: LexicalCommand<void>;
15
15
  export declare const CONTROLLED_TEXT_INSERTION_COMMAND: LexicalCommand<InputEvent | string>;
16
- export declare const PASTE_COMMAND: LexicalCommand<ClipboardEvent | InputEvent>;
16
+ export declare const PASTE_COMMAND: LexicalCommand<ClipboardEvent | InputEvent | KeyboardEvent>;
17
17
  export declare const REMOVE_TEXT_COMMAND: LexicalCommand<void>;
18
18
  export declare const DELETE_WORD_COMMAND: LexicalCommand<boolean>;
19
19
  export declare const DELETE_LINE_COMMAND: LexicalCommand<boolean>;
@@ -15,7 +15,6 @@ export declare const FULL_RECONCILE = 2;
15
15
  export declare const IS_NORMAL = 0;
16
16
  export declare const IS_TOKEN = 1;
17
17
  export declare const IS_SEGMENTED = 2;
18
- export declare const IS_INERT = 3;
19
18
  export declare const IS_BOLD = 1;
20
19
  export declare const IS_ITALIC: number;
21
20
  export declare const IS_STRIKETHROUGH: number;
@@ -40,5 +39,5 @@ export declare const TEXT_TYPE_TO_FORMAT: Record<TextFormatType | string, number
40
39
  export declare const DETAIL_TYPE_TO_DETAIL: Record<TextDetailType | string, number>;
41
40
  export declare const ELEMENT_TYPE_TO_FORMAT: Record<Exclude<ElementFormatType, ''>, number>;
42
41
  export declare const ELEMENT_FORMAT_TO_TYPE: Record<number, ElementFormatType>;
43
- export declare const TEXT_MODE_TO_TYPE: Record<TextModeType, 0 | 1 | 2 | 3>;
42
+ export declare const TEXT_MODE_TO_TYPE: Record<TextModeType, 0 | 1 | 2>;
44
43
  export declare const TEXT_TYPE_TO_MODE: Record<number, TextModeType>;
@@ -70,9 +70,20 @@ export declare type EditorThemeClasses = {
70
70
  root?: EditorThemeClassName;
71
71
  rtl?: EditorThemeClassName;
72
72
  table?: EditorThemeClassName;
73
+ tableAddColumns?: EditorThemeClassName;
74
+ tableAddRows?: EditorThemeClassName;
75
+ tableCellActionButton?: EditorThemeClassName;
76
+ tableCellActionButtonContainer?: EditorThemeClassName;
77
+ tableCellPrimarySelected?: EditorThemeClassName;
78
+ tableCellSelected?: EditorThemeClassName;
73
79
  tableCell?: EditorThemeClassName;
80
+ tableCellEditing?: EditorThemeClassName;
74
81
  tableCellHeader?: EditorThemeClassName;
82
+ tableCellResizer?: EditorThemeClassName;
83
+ tableCellSortedIndicator?: EditorThemeClassName;
84
+ tableResizeRuler?: EditorThemeClassName;
75
85
  tableRow?: EditorThemeClassName;
86
+ tableSelected?: EditorThemeClassName;
76
87
  text?: TextNodeThemeClasses;
77
88
  embedBlock?: {
78
89
  base?: EditorThemeClassName;
package/LexicalNode.d.ts CHANGED
@@ -19,7 +19,7 @@ export declare type DOMConversion<T extends HTMLElement = HTMLElement> = {
19
19
  conversion: DOMConversionFn<T>;
20
20
  priority: 0 | 1 | 2 | 3 | 4;
21
21
  };
22
- export declare type DOMConversionFn<T extends HTMLElement = HTMLElement> = (element: T, parent?: Node) => DOMConversionOutput | null;
22
+ export declare type DOMConversionFn<T extends HTMLElement = HTMLElement> = (element: T, parent?: Node, preformatted?: boolean) => DOMConversionOutput | null;
23
23
  export declare type DOMChildConversion = (lexicalNode: LexicalNode, parentLexicalNode: LexicalNode | null | undefined) => LexicalNode | null | undefined;
24
24
  export declare type DOMConversionMap<T extends HTMLElement = HTMLElement> = Record<NodeName, (node: T) => DOMConversion<T> | null>;
25
25
  declare type NodeName = string;
@@ -27,6 +27,7 @@ export declare type DOMConversionOutput = {
27
27
  after?: (childLexicalNodes: Array<LexicalNode>) => Array<LexicalNode>;
28
28
  forChild?: DOMChildConversion;
29
29
  node: LexicalNode | null;
30
+ preformatted?: boolean;
30
31
  };
31
32
  export declare type DOMExportOutput = {
32
33
  after?: (generatedElement: HTMLElement | null | undefined) => HTMLElement | null | undefined;
@@ -67,8 +68,8 @@ export declare class LexicalNode {
67
68
  isDirty(): boolean;
68
69
  getLatest(): this;
69
70
  getWritable(): this;
70
- getTextContent(_includeInert?: boolean, _includeDirectionless?: false): string;
71
- getTextContentSize(includeInert?: boolean, includeDirectionless?: false): number;
71
+ getTextContent(): string;
72
+ getTextContentSize(): number;
72
73
  createDOM(_config: EditorConfig, _editor: LexicalEditor): HTMLElement;
73
74
  updateDOM(_prevNode: unknown, _dom: HTMLElement, _config: EditorConfig): boolean;
74
75
  exportDOM(editor: LexicalEditor): DOMExportOutput;
@@ -5,5 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import type { TextNode } from '.';
8
+ import type { RangeSelection, TextNode } from '.';
9
9
  export declare function $normalizeTextNode(textNode: TextNode): void;
10
+ export declare function $normalizeSelection(selection: RangeSelection): RangeSelection;
@@ -69,6 +69,7 @@ export declare class NodeSelection implements BaseSelection {
69
69
  extract(): Array<LexicalNode>;
70
70
  insertRawText(text: string): void;
71
71
  insertText(): void;
72
+ insertNodes(nodes: Array<LexicalNode>, selectStart?: boolean): boolean;
72
73
  getNodes(): Array<LexicalNode>;
73
74
  getTextContent(): string;
74
75
  }
@@ -95,11 +96,12 @@ export declare class GridSelection implements BaseSelection {
95
96
  extract(): Array<LexicalNode>;
96
97
  insertRawText(text: string): void;
97
98
  insertText(): void;
99
+ insertNodes(nodes: Array<LexicalNode>, selectStart?: boolean): boolean;
98
100
  getShape(): GridSelectionShape;
99
101
  getNodes(): Array<LexicalNode>;
100
102
  getTextContent(): string;
101
103
  }
102
- export declare function $isGridSelection(x: unknown): x is GridSelection;
104
+ export declare function DEPRECATED_$isGridSelection(x: unknown): x is GridSelection;
103
105
  export declare class RangeSelection implements BaseSelection {
104
106
  anchor: PointType;
105
107
  focus: PointType;
@@ -135,7 +137,7 @@ export declare function $isNodeSelection(x: unknown): x is NodeSelection;
135
137
  export declare function internalMakeRangeSelection(anchorKey: NodeKey, anchorOffset: number, focusKey: NodeKey, focusOffset: number, anchorType: 'text' | 'element', focusType: 'text' | 'element'): RangeSelection;
136
138
  export declare function $createRangeSelection(): RangeSelection;
137
139
  export declare function $createNodeSelection(): NodeSelection;
138
- export declare function $createGridSelection(): GridSelection;
140
+ export declare function DEPRECATED_$createGridSelection(): GridSelection;
139
141
  export declare function internalCreateSelection(editor: LexicalEditor): null | RangeSelection | NodeSelection | GridSelection;
140
142
  export declare function internalCreateRangeSelection(lastSelection: null | RangeSelection | NodeSelection | GridSelection, domSelection: Selection | null, editor: LexicalEditor): null | RangeSelection;
141
143
  export declare function $getSelection(): null | RangeSelection | NodeSelection | GridSelection;
@@ -145,3 +147,4 @@ export declare function applySelectionTransforms(nextEditorState: EditorState, e
145
147
  export declare function moveSelectionPointToSibling(point: PointType, node: LexicalNode, parent: ElementNode, prevSibling: LexicalNode | null, nextSibling: LexicalNode | null): void;
146
148
  export declare function adjustPointOffsetForMergedSibling(point: PointType, isBefore: boolean, key: NodeKey, target: TextNode, textLength: number): void;
147
149
  export declare function updateDOMSelection(prevSelection: RangeSelection | NodeSelection | GridSelection | null, nextSelection: RangeSelection | NodeSelection | GridSelection | null, editor: LexicalEditor, domSelection: Selection, tags: Set<string>, rootElement: HTMLElement): void;
150
+ export declare function $insertNodes(nodes: Array<LexicalNode>, selectStart?: boolean): boolean;
package/LexicalUtils.d.ts CHANGED
@@ -24,8 +24,7 @@ export declare function isSelectionCapturedInDecoratorInput(anchorDOM: Node): bo
24
24
  export declare function isSelectionWithinEditor(editor: LexicalEditor, anchorDOM: null | Node, focusDOM: null | Node): boolean;
25
25
  export declare function getNearestEditorFromDOMNode(node: Node | null): LexicalEditor | null;
26
26
  export declare function getTextDirection(text: string): 'ltr' | 'rtl' | null;
27
- export declare function $isTokenOrInertOrSegmented(node: TextNode): boolean;
28
- export declare function $isTokenOrInert(node: TextNode): boolean;
27
+ export declare function $isTokenOrSegmented(node: TextNode): boolean;
29
28
  export declare function getDOMTextNode(element: Node | null): Text | null;
30
29
  export declare function toggleTextFormatType(format: number, type: TextFormatType, alignWithFormat: null | number): number;
31
30
  export declare function $isLeafNode(node: LexicalNode | null | undefined): node is TextNode | LineBreakNode | DecoratorNode<unknown>;
@@ -95,5 +94,8 @@ export declare function scrollIntoViewIfNeeded(editor: LexicalEditor, anchor: Po
95
94
  export declare function $hasUpdateTag(tag: string): boolean;
96
95
  export declare function $addUpdateTag(tag: string): void;
97
96
  export declare function $maybeMoveChildrenSelectionToParent(parentNode: LexicalNode, offset?: number): RangeSelection | NodeSelection | GridSelection | null;
97
+ export declare function $hasAncestor(child: LexicalNode, targetNode: LexicalNode): boolean;
98
98
  export declare function getDefaultView(domElem: HTMLElement): Window | null;
99
99
  export declare function getWindow(editor: LexicalEditor): Window;
100
+ export declare function $isInlineElementOrDecoratorNode(node: LexicalNode): boolean;
101
+ export declare function $isRootOrShadowRoot(node: null | LexicalNode): boolean;
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- export declare const VERSION = "0.4.0";
8
+ export declare const VERSION = "0.4.1";
package/index.d.ts CHANGED
@@ -17,15 +17,15 @@ export type { SerializedTextNode, TextFormatType, TextModeType, } from './nodes/
17
17
  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';
18
18
  export { COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, createEditor, } from './LexicalEditor';
19
19
  export type { EventHandler } from './LexicalEvents';
20
- export { $createGridSelection, $createNodeSelection, $createRangeSelection, $getPreviousSelection, $getSelection, $isGridSelection, $isNodeSelection, $isRangeSelection, } from './LexicalSelection';
20
+ export { $createNodeSelection, $createRangeSelection, $getPreviousSelection, $getSelection, $insertNodes, $isNodeSelection, $isRangeSelection, DEPRECATED_$createGridSelection, DEPRECATED_$isGridSelection, } from './LexicalSelection';
21
21
  export { $parseSerializedNode } from './LexicalUpdates';
22
- export { $getDecoratorNode, $getNearestNodeFromDOMNode, $getNodeByKey, $getRoot, $isLeafNode, $nodesOfType, $setCompositionKey, $setSelection, } from './LexicalUtils';
22
+ export { $addUpdateTag, $getDecoratorNode, $getNearestNodeFromDOMNode, $getNodeByKey, $getRoot, $hasAncestor, $isInlineElementOrDecoratorNode, $isLeafNode, $isRootOrShadowRoot, $nodesOfType, $setCompositionKey, $setSelection, } from './LexicalUtils';
23
23
  export { VERSION } from './LexicalVersion';
24
24
  export { $isDecoratorNode, DecoratorNode } from './nodes/LexicalDecoratorNode';
25
25
  export { $isElementNode, ElementNode } from './nodes/LexicalElementNode';
26
- export { $isGridCellNode, GridCellNode } from './nodes/LexicalGridCellNode';
27
- export { $isGridNode, GridNode } from './nodes/LexicalGridNode';
28
- export { $isGridRowNode, GridRowNode } from './nodes/LexicalGridRowNode';
26
+ export { DEPRECATED_$isGridCellNode, DEPRECATED_GridCellNode, } from './nodes/LexicalGridCellNode';
27
+ export { DEPRECATED_$isGridNode, DEPRECATED_GridNode, } from './nodes/LexicalGridNode';
28
+ export { DEPRECATED_$isGridRowNode, DEPRECATED_GridRowNode, } from './nodes/LexicalGridRowNode';
29
29
  export type { SerializedLineBreakNode } from './nodes/LexicalLineBreakNode';
30
30
  export { $createLineBreakNode, $isLineBreakNode, LineBreakNode, } from './nodes/LexicalLineBreakNode';
31
31
  export type { SerializedParagraphNode } from './nodes/LexicalParagraphNode';
@@ -14,6 +14,6 @@ export declare class DecoratorNode<T> extends LexicalNode {
14
14
  constructor(key?: NodeKey);
15
15
  decorate(editor: LexicalEditor, config: EditorConfig): T;
16
16
  isIsolated(): boolean;
17
- isTopLevel(): boolean;
17
+ isInline(): boolean;
18
18
  }
19
19
  export declare function $isDecoratorNode<T>(node: LexicalNode | null | undefined): node is DecoratorNode<T>;
@@ -37,15 +37,16 @@ export declare class ElementNode extends LexicalNode {
37
37
  isEmpty(): boolean;
38
38
  isDirty(): boolean;
39
39
  isLastChild(): boolean;
40
- getAllTextNodes(includeInert?: boolean): Array<TextNode>;
40
+ getAllTextNodes(): Array<TextNode>;
41
41
  getFirstDescendant<T extends LexicalNode>(): null | T;
42
42
  getLastDescendant<T extends LexicalNode>(): null | T;
43
43
  getDescendantByIndex<T extends LexicalNode>(index: number): null | T;
44
44
  getFirstChild<T extends LexicalNode>(): null | T;
45
45
  getFirstChildOrThrow<T extends LexicalNode>(): T;
46
46
  getLastChild<T extends LexicalNode>(): null | T;
47
+ getLastChildOrThrow<T extends LexicalNode>(): T;
47
48
  getChildAtIndex<T extends LexicalNode>(index: number): null | T;
48
- getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
49
+ getTextContent(): string;
49
50
  getDirection(): 'ltr' | 'rtl' | null;
50
51
  hasFormat(type: ElementFormatType): boolean;
51
52
  select(_anchorOffset?: number, _focusOffset?: number): RangeSelection;
@@ -70,6 +71,7 @@ export declare class ElementNode extends LexicalNode {
70
71
  canInsertTextBefore(): boolean;
71
72
  canInsertTextAfter(): boolean;
72
73
  isInline(): boolean;
74
+ isShadowRoot(): boolean;
73
75
  canMergeWith(node: ElementNode): boolean;
74
76
  extractWithChild(child: LexicalNode, selection: RangeSelection | NodeSelection | GridSelection | null, destination: 'clone' | 'html'): boolean;
75
77
  }
@@ -11,10 +11,10 @@ export declare type SerializedGridCellNode = Spread<{
11
11
  colSpan: number;
12
12
  }, SerializedElementNode>;
13
13
  /** @noInheritDoc */
14
- export declare class GridCellNode extends ElementNode {
14
+ export declare class DEPRECATED_GridCellNode extends ElementNode {
15
15
  /** @internal */
16
16
  __colSpan: number;
17
17
  constructor(colSpan: number, key?: NodeKey);
18
18
  exportJSON(): SerializedGridCellNode;
19
19
  }
20
- export declare function $isGridCellNode(node: GridCellNode | LexicalNode | null | undefined): node is GridCellNode;
20
+ export declare function DEPRECATED_$isGridCellNode(node: DEPRECATED_GridCellNode | LexicalNode | null | undefined): node is DEPRECATED_GridCellNode;
@@ -7,6 +7,6 @@
7
7
  */
8
8
  import type { LexicalNode } from '../LexicalNode';
9
9
  import { ElementNode } from './LexicalElementNode';
10
- export declare class GridNode extends ElementNode {
10
+ export declare class DEPRECATED_GridNode extends ElementNode {
11
11
  }
12
- export declare function $isGridNode(node: LexicalNode | null | undefined): node is GridNode;
12
+ export declare function DEPRECATED_$isGridNode(node: LexicalNode | null | undefined): node is DEPRECATED_GridNode;
@@ -7,6 +7,6 @@
7
7
  */
8
8
  import type { LexicalNode } from '../LexicalNode';
9
9
  import { ElementNode } from './LexicalElementNode';
10
- export declare class GridRowNode extends ElementNode {
10
+ export declare class DEPRECATED_GridRowNode extends ElementNode {
11
11
  }
12
- export declare function $isGridRowNode(node: LexicalNode | null | undefined): node is GridRowNode;
12
+ export declare function DEPRECATED_$isGridRowNode(node: LexicalNode | null | undefined): node is DEPRECATED_GridRowNode;
@@ -17,7 +17,7 @@ export declare class RootNode extends ElementNode {
17
17
  static clone(): RootNode;
18
18
  constructor();
19
19
  getTopLevelElementOrThrow(): never;
20
- getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
20
+ getTextContent(): string;
21
21
  remove(): never;
22
22
  replace<N = LexicalNode>(node: N): never;
23
23
  insertBefore(nodeToInsert: LexicalNode): LexicalNode;
@@ -17,9 +17,9 @@ export declare type SerializedTextNode = Spread<{
17
17
  style: string;
18
18
  text: string;
19
19
  }, SerializedLexicalNode>;
20
- export declare type TextFormatType = 'bold' | 'underline' | 'strikethrough' | 'italic' | 'code' | 'subscript' | 'superscript';
21
20
  export declare type TextDetailType = 'directionless' | 'unmergable';
22
- export declare type TextModeType = 'normal' | 'token' | 'segmented' | 'inert';
21
+ export declare type TextFormatType = 'bold' | 'underline' | 'strikethrough' | 'italic' | 'code' | 'subscript' | 'superscript';
22
+ export declare type TextModeType = 'normal' | 'token' | 'segmented';
23
23
  export declare type TextMark = {
24
24
  end: null | number;
25
25
  id: string;
@@ -43,12 +43,11 @@ export declare class TextNode extends LexicalNode {
43
43
  isToken(): boolean;
44
44
  isComposing(): boolean;
45
45
  isSegmented(): boolean;
46
- isInert(): boolean;
47
46
  isDirectionless(): boolean;
48
47
  isUnmergeable(): boolean;
49
48
  hasFormat(type: TextFormatType): boolean;
50
49
  isSimpleText(): boolean;
51
- getTextContent(includeInert?: boolean, includeDirectionless?: false): string;
50
+ getTextContent(): string;
52
51
  getFormatFlags(type: TextFormatType, alignWithFormat: null | number): number;
53
52
  createDOM(config: EditorConfig): HTMLElement;
54
53
  updateDOM(prevNode: TextNode, dom: HTMLElement, config: EditorConfig): boolean;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "rich-text"
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "0.4.0",
12
+ "version": "0.5.0",
13
13
  "main": "Lexical.js",
14
14
  "repository": {
15
15
  "type": "git",