Skip to main content

@lexical/table

Classes​

TableCellNode​

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:56

Extends​

Constructors​

Constructor​

new TableCellNode(headerState?, colSpan?, width?, key?): TableCellNode

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:109

Parameters​
headerState?​

number = TableCellHeaderStates.NO_STATUS

colSpan?​

number = 1

width?​

number

key?​

string

Returns​

TableCellNode

Overrides​

ElementNode.constructor

Methods​

$config()​

$config(): BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"tablecell"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; importDOM: { td: () => object; th: () => object; }; }>

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:70

Override this to implement the new static node configuration protocol, this method is called directly on the prototype and must not depend on anything initialized in the constructor. Generally it should be a trivial implementation.

Returns​

BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"tablecell"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; importDOM: { td: () => object; th: () => object; }; }>

Example​
class MyNode extends TextNode {
$config() {
return this.config('my-node', {extends: TextNode});
}
}
Overrides​

ElementNode.$config

afterCloneFrom()​

afterCloneFrom(node): void

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:86

Perform any state updates on the clone of prevNode that are not already handled by the constructor call in the static clone method. If you have state to update in your clone that is not handled directly by the constructor, it is advisable to override this method but it is required to include a call to super.afterCloneFrom(prevNode) in your implementation. This is only intended to be called by $cloneWithProperties function or via a super call.

Parameters​
node​

this

Returns​

void

Example​
class ClassesTextNode extends TextNode {
// Not shown: static getType, static importJSON, exportJSON, createDOM, updateDOM
__classes = new Set<string>();
static clone(node: ClassesTextNode): ClassesTextNode {
// The inherited TextNode constructor is used here, so
// classes is not set by this method.
return new ClassesTextNode(node.__text, node.__key);
}
afterCloneFrom(node: this): void {
// This calls TextNode.afterCloneFrom and LexicalNode.afterCloneFrom
// for necessary state updates
super.afterCloneFrom(node);
this.__addClasses(node.__classes);
}
// This method is a private implementation detail, it is not
// suitable for the public API because it does not call getWritable
__addClasses(classNames: Iterable<string>): this {
for (const className of classNames) {
this.__classes.add(className);
}
return this;
}
addClass(...classNames: string[]): this {
return this.getWritable().__addClasses(classNames);
}
removeClass(...classNames: string[]): this {
const node = this.getWritable();
for (const className of classNames) {
this.__classes.delete(className);
}
return this;
}
getClasses(): Set<string> {
return this.getLatest().__classes;
}
}
Overrides​

ElementNode.afterCloneFrom

canBeEmpty()​

canBeEmpty(): false

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:300

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:304

Returns​

false

Overrides​

ElementNode.canIndent

collapseAtStart()​

collapseAtStart(): true

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:296

Returns​

true

Overrides​

ElementNode.collapseAtStart

createDOM()​

createDOM(config): HTMLTableCellElement

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:124

Called during the reconciliation process to determine which nodes to insert into the DOM for this Lexical Node.

This method must return exactly one HTMLElement. Nested elements are not supported.

Do not attempt to update the Lexical EditorState during this phase of the update lifecycle.

Parameters​
config​

EditorConfig

Returns​

HTMLTableCellElement

Overrides​

ElementNode.createDOM

exportDOM()​

exportDOM(editor): DOMExportOutput

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:152

Controls how the this node is serialized to HTML. This is important for copy and paste between Lexical and non-Lexical editors, or Lexical editors with different namespaces, in which case the primary transfer format is HTML. It's also important if you're serializing to HTML for any other reason via $generateHtmlFromNodes. You could also use this method to build your own HTML renderer.

Parameters​
editor​

LexicalEditor

Returns​

DOMExportOutput

Overrides​

ElementNode.exportDOM

exportJSON()​

exportJSON(): SerializedTableCellNode

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:180

Controls how the this node is serialized to JSON. This is important for copy and paste between Lexical editors sharing the same namespace. It's also important if you're serializing to JSON for persistent storage somewhere. See Serialization & Deserialization.

Returns​

SerializedTableCellNode

Overrides​

ElementNode.exportJSON

getBackgroundColor()​

getBackgroundColor(): string | null

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:241

Returns​

string | null

getColSpan()​

getColSpan(): number

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:194

Returns​

number

getHeaderStyles()​

getHeaderStyles(): number

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:227

Returns​

number

getRowSpan()​

getRowSpan(): number

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:204

Returns​

number

getTag()​

getTag(): "td" | "th"

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:214

Returns​

"td" | "th"

getVerticalAlign()​

getVerticalAlign(): string | undefined

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:251

Returns​

string | undefined

getWidth()​

getWidth(): number | undefined

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:237

Returns​

number | undefined

hasHeader()​

hasHeader(): boolean

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:277

Returns​

boolean

hasHeaderState()​

hasHeaderState(headerState): boolean

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:273

Parameters​
headerState​

number

Returns​

boolean

isShadowRoot()​

isShadowRoot(): boolean

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:292

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

setBackgroundColor()​

setBackgroundColor(newBackgroundColor): this

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:245

Parameters​
newBackgroundColor​

string | null

Returns​

this

setColSpan()​

setColSpan(colSpan): this

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:198

Parameters​
colSpan​

number

Returns​

this

setHeaderStyles()​

setHeaderStyles(headerState, mask?): this

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:218

Parameters​
headerState​

number

mask?​

number = TableCellHeaderStates.BOTH

Returns​

this

setRowSpan()​

setRowSpan(rowSpan): this

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:208

Parameters​
rowSpan​

number

Returns​

this

setVerticalAlign()​

setVerticalAlign(newVerticalAlign): this

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:255

Parameters​
newVerticalAlign​

string | null | undefined

Returns​

this

setWidth()​

setWidth(width): this

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:231

Parameters​
width​

number | undefined

Returns​

this

toggleHeaderStyle()​

toggleHeaderStyle(headerStateToToggle): this

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:261

Parameters​
headerStateToToggle​

number

Returns​

this

updateDOM()​

updateDOM(prevNode): boolean

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:281

Called when a node changes and should update the DOM in whatever way is necessary to make it align with any changes that might have happened during the update.

Returning "true" here will cause lexical to unmount and recreate the DOM node (by calling createDOM). You would need to do this if the element tag changes, for instance.

Parameters​
prevNode​

this

Returns​

boolean

Overrides​

ElementNode.updateDOM

updateFromJSON()​

updateFromJSON(serializedNode): this

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:96

Update this LexicalNode instance from serialized JSON. It's recommended to implement as much logic as possible in this method instead of the static importJSON method, so that the functionality can be inherited in subclasses.

The LexicalUpdateJSON utility type should be used to ignore any type, version, or children properties in the JSON so that the extended JSON from subclasses are acceptable parameters for the super call.

If overridden, this method must call super.

Parameters​
serializedNode​

LexicalUpdateJSON<SerializedTableCellNode>

Returns​

this

Example​
class MyTextNode extends TextNode {
// ...
static importJSON(serializedNode: SerializedMyTextNode): MyTextNode {
return $createMyTextNode()
.updateFromJSON(serializedNode);
}
updateFromJSON(
serializedNode: LexicalUpdateJSON<SerializedMyTextNode>,
): this {
return super.updateFromJSON(serializedNode)
.setMyProperty(serializedNode.myProperty);
}
}
Overrides​

ElementNode.updateFromJSON


TableNode​

Defined in: packages/lexical-table/src/LexicalTableNode.ts:371

Extends​

Properties​

__colWidths​

__colWidths: readonly number[] | undefined = undefined

Defined in: packages/lexical-table/src/LexicalTableNode.ts:380

__frozenColumnCount​

__frozenColumnCount: number = 0

Defined in: packages/lexical-table/src/LexicalTableNode.ts:374

__frozenRowCount​

__frozenRowCount: number = 0

Defined in: packages/lexical-table/src/LexicalTableNode.ts:375

Methods​

$config()​

$config(): BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"table"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; importDOM: { table: () => object; }; }>

Defined in: packages/lexical-table/src/LexicalTableNode.ts:382

Override this to implement the new static node configuration protocol, this method is called directly on the prototype and must not depend on anything initialized in the constructor. Generally it should be a trivial implementation.

Returns​

BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"table"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; importDOM: { table: () => object; }; }>

Example​
class MyNode extends TextNode {
$config() {
return this.config('my-node', {extends: TextNode});
}
}
Overrides​

ElementNode.$config

afterCloneFrom()​

afterCloneFrom(prevNode): void

Defined in: packages/lexical-table/src/LexicalTableNode.ts:407

Perform any state updates on the clone of prevNode that are not already handled by the constructor call in the static clone method. If you have state to update in your clone that is not handled directly by the constructor, it is advisable to override this method but it is required to include a call to super.afterCloneFrom(prevNode) in your implementation. This is only intended to be called by $cloneWithProperties function or via a super call.

Parameters​
prevNode​

this

Returns​

void

Example​
class ClassesTextNode extends TextNode {
// Not shown: static getType, static importJSON, exportJSON, createDOM, updateDOM
__classes = new Set<string>();
static clone(node: ClassesTextNode): ClassesTextNode {
// The inherited TextNode constructor is used here, so
// classes is not set by this method.
return new ClassesTextNode(node.__text, node.__key);
}
afterCloneFrom(node: this): void {
// This calls TextNode.afterCloneFrom and LexicalNode.afterCloneFrom
// for necessary state updates
super.afterCloneFrom(node);
this.__addClasses(node.__classes);
}
// This method is a private implementation detail, it is not
// suitable for the public API because it does not call getWritable
__addClasses(classNames: Iterable<string>): this {
for (const className of classNames) {
this.__classes.add(className);
}
return this;
}
addClass(...classNames: string[]): this {
return this.getWritable().__addClasses(classNames);
}
removeClass(...classNames: string[]): this {
const node = this.getWritable();
for (const className of classNames) {
this.__classes.delete(className);
}
return this;
}
getClasses(): Set<string> {
return this.getLatest().__classes;
}
}
Overrides​

ElementNode.afterCloneFrom

canBeEmpty()​

canBeEmpty(): false

Defined in: packages/lexical-table/src/LexicalTableNode.ts:656

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

Defined in: packages/lexical-table/src/LexicalTableNode.ts:799

Returns​

false

Overrides​

ElementNode.canIndent

canSelectBefore()​

canSelectBefore(): true

Defined in: packages/lexical-table/src/LexicalTableNode.ts:795

Returns​

true

createDOM()​

createDOM(config, editor?): HTMLElement

Defined in: packages/lexical-table/src/LexicalTableNode.ts:458

Called during the reconciliation process to determine which nodes to insert into the DOM for this Lexical Node.

This method must return exactly one HTMLElement. Nested elements are not supported.

Do not attempt to update the Lexical EditorState during this phase of the update lifecycle.

Parameters​
config​

EditorConfig

editor?​

LexicalEditor

Returns​

HTMLElement

Overrides​

ElementNode.createDOM

exportDOM()​

exportDOM(editor): DOMExportOutput

Defined in: packages/lexical-table/src/LexicalTableNode.ts:574

Controls how the this node is serialized to HTML. This is important for copy and paste between Lexical and non-Lexical editors, or Lexical editors with different namespaces, in which case the primary transfer format is HTML. It's also important if you're serializing to HTML for any other reason via $generateHtmlFromNodes. You could also use this method to build your own HTML renderer.

Parameters​
editor​

LexicalEditor

Returns​

DOMExportOutput

Overrides​

ElementNode.exportDOM

exportJSON()​

exportJSON(): SerializedTableNode

Defined in: packages/lexical-table/src/LexicalTableNode.ts:424

Controls how the this node is serialized to JSON. This is important for copy and paste between Lexical editors sharing the same namespace. It's also important if you're serializing to JSON for persistent storage somewhere. See Serialization & Deserialization.

Returns​

SerializedTableNode

Overrides​

ElementNode.exportJSON

extractWithChild()​

extractWithChild(child, selection, destination): boolean

Defined in: packages/lexical-table/src/LexicalTableNode.ts:436

Parameters​
child​

LexicalNode

selection​

BaseSelection | null

destination​

"clone" | "html"

Returns​

boolean

Overrides​

ElementNode.extractWithChild

getCellNodeFromCords()​

getCellNodeFromCords(x, y, table): TableCellNode | null

Defined in: packages/lexical-table/src/LexicalTableNode.ts:731

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableCellNode | null

getCellNodeFromCordsOrThrow()​

getCellNodeFromCordsOrThrow(x, y, table): TableCellNode

Defined in: packages/lexical-table/src/LexicalTableNode.ts:751

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableCellNode

getColumnCount()​

getColumnCount(): number

Defined in: packages/lexical-table/src/LexicalTableNode.ts:803

Returns​

number

getColWidths()​

getColWidths(): readonly number[] | undefined

Defined in: packages/lexical-table/src/LexicalTableNode.ts:394

Returns​

readonly number[] | undefined

getCordsFromCellNode()​

getCordsFromCellNode(tableCellNode, table): object

Defined in: packages/lexical-table/src/LexicalTableNode.ts:664

Parameters​
tableCellNode​

TableCellNode

table​

TableDOMTable

Returns​

object

x​

x: number

y​

y: number

getDOMCellFromCords()​

getDOMCellFromCords(x, y, table): TableDOMCell | null

Defined in: packages/lexical-table/src/LexicalTableNode.ts:693

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableDOMCell | null

getDOMCellFromCordsOrThrow()​

getDOMCellFromCordsOrThrow(x, y, table): TableDOMCell

Defined in: packages/lexical-table/src/LexicalTableNode.ts:717

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableDOMCell

getDOMSlot()​

getDOMSlot(element): ElementDOMSlot<HTMLTableElement>

Defined in: packages/lexical-table/src/LexicalTableNode.ts:444

Experimental

An ElementNode subclass can override this to control where its children are inserted into the DOM, e.g. to add a wrapping node or accessory nodes before or after the children. The root of the node returned by createDOM must still be exactly one HTMLElement.

Parameters​
element​

HTMLElement

Returns​

ElementDOMSlot<HTMLTableElement>

Overrides​

ElementNode.getDOMSlot

getFrozenColumns()​

getFrozenColumns(): number

Defined in: packages/lexical-table/src/LexicalTableNode.ts:781

Returns​

number

getFrozenRows()​

getFrozenRows(): number

Defined in: packages/lexical-table/src/LexicalTableNode.ts:791

Returns​

number

getRowStriping()​

getRowStriping(): boolean

Defined in: packages/lexical-table/src/LexicalTableNode.ts:765

Returns​

boolean

isShadowRoot()​

isShadowRoot(): boolean

Defined in: packages/lexical-table/src/LexicalTableNode.ts:660

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

scaleDOMColWidths()​

scaleDOMColWidths(dom, scale): void

Defined in: packages/lexical-table/src/LexicalTableNode.ts:561

Parameters​
dom​

HTMLElement

scale​

number

Returns​

void

setColWidths()​

setColWidths(colWidths): this

Defined in: packages/lexical-table/src/LexicalTableNode.ts:399

Parameters​
colWidths​

readonly number[] | undefined

Returns​

this

setFrozenColumns()​

setFrozenColumns(columnCount): this

Defined in: packages/lexical-table/src/LexicalTableNode.ts:775

Parameters​
columnCount​

number

Returns​

this

setFrozenRows()​

setFrozenRows(rowCount): this

Defined in: packages/lexical-table/src/LexicalTableNode.ts:785

Parameters​
rowCount​

number

Returns​

this

setRowStriping()​

setRowStriping(newRowStriping): this

Defined in: packages/lexical-table/src/LexicalTableNode.ts:769

Parameters​
newRowStriping​

boolean

Returns​

this

updateDOM()​

updateDOM(prevNode, dom, config): boolean

Defined in: packages/lexical-table/src/LexicalTableNode.ts:540

Called when a node changes and should update the DOM in whatever way is necessary to make it align with any changes that might have happened during the update.

Returning "true" here will cause lexical to unmount and recreate the DOM node (by calling createDOM). You would need to do this if the element tag changes, for instance.

Parameters​
prevNode​

this

dom​

HTMLElement

config​

EditorConfig

Returns​

boolean

Overrides​

ElementNode.updateDOM

updateFromJSON()​

updateFromJSON(serializedNode): this

Defined in: packages/lexical-table/src/LexicalTableNode.ts:415

Update this LexicalNode instance from serialized JSON. It's recommended to implement as much logic as possible in this method instead of the static importJSON method, so that the functionality can be inherited in subclasses.

The LexicalUpdateJSON utility type should be used to ignore any type, version, or children properties in the JSON so that the extended JSON from subclasses are acceptable parameters for the super call.

If overridden, this method must call super.

Parameters​
serializedNode​

LexicalUpdateJSON<SerializedTableNode>

Returns​

this

Example​
class MyTextNode extends TextNode {
// ...
static importJSON(serializedNode: SerializedMyTextNode): MyTextNode {
return $createMyTextNode()
.updateFromJSON(serializedNode);
}
updateFromJSON(
serializedNode: LexicalUpdateJSON<SerializedMyTextNode>,
): this {
return super.updateFromJSON(serializedNode)
.setMyProperty(serializedNode.myProperty);
}
}
Overrides​

ElementNode.updateFromJSON

updateTableElement()​

updateTableElement(prevNode, tableElement, config): void

Defined in: packages/lexical-table/src/LexicalTableNode.ts:514

Parameters​
prevNode​

TableNode | null

tableElement​

HTMLTableElement

config​

EditorConfig

Returns​

void

updateTableWrapper()​

updateTableWrapper(prevNode, tableWrapper, tableElement, config): void

Defined in: packages/lexical-table/src/LexicalTableNode.ts:493

Parameters​
prevNode​

TableNode | null

tableWrapper​

HTMLDivElement

tableElement​

HTMLTableElement

config​

EditorConfig

Returns​

void


TableObserver​

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:215

Constructors​

Constructor​

new TableObserver(editor, tableNodeKey): TableObserver

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:236

Parameters​
editor​

LexicalEditor

tableNodeKey​

string

Returns​

TableObserver

Properties​

abortController​

abortController: AbortController

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:233

anchorCell​

anchorCell: TableDOMCell | null

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:224

anchorCellNodeKey​

anchorCellNodeKey: string | null

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:226

anchorX​

anchorX: number

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:221

anchorY​

anchorY: number

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:222

editor​

editor: LexicalEditor

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:228

focusCell​

focusCell: TableDOMCell | null

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:225

focusCellNodeKey​

focusCellNodeKey: string | null

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:227

focusX​

focusX: number

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:216

focusY​

focusY: number

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:217

hasHijackedSelectionStyles​

hasHijackedSelectionStyles: boolean

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:230

isHighlightingCells​

isHighlightingCells: boolean

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:220

isSelecting​

isSelecting: boolean

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:231

listenerOptions​

listenerOptions: object

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:234

signal​

signal: AbortSignal

listenersToRemove​

listenersToRemove: Set<() => void>

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:218

pointerType​

pointerType: string | null

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:232

table​

table: TableDOMTable

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:219

tableNodeKey​

tableNodeKey: string

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:223

tableSelection​

tableSelection: TableSelection | null

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:229

Methods​

$clearHighlight()​

$clearHighlight(setEmptySelection?): void

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:322

Parameters​
setEmptySelection?​

boolean = true

Returns​

void

$clearText()​

$clearText(): void

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:568

Returns​

void

$disableHighlightStyle()​

$disableHighlightStyle(): void

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:359

Returns​

void

$enableHighlightStyle()​

$enableHighlightStyle(): void

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:347

Returns​

void

$formatCells()​

$formatCells(type): void

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:540

Parameters​
type​

TextFormatType

Returns​

void

$getAnchorTableCell()​

$getAnchorTableCell(): TableCellNode | null

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:475

Returns​

TableCellNode | null

$getAnchorTableCellOrThrow()​

$getAnchorTableCellOrThrow(): TableCellNode

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:481

Returns​

TableCellNode

$getFocusTableCell()​

$getFocusTableCell(): TableCellNode | null

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:490

Returns​

TableCellNode | null

$getFocusTableCellOrThrow()​

$getFocusTableCellOrThrow(): TableCellNode

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:497

Returns​

TableCellNode

$lookup()​

$lookup(): object

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:275

Returns​

object

tableElement​

tableElement: HTMLTableElementWithWithTableSelectionState

tableNode​

tableNode: TableNode

$setAnchorCellForSelection()​

$setAnchorCellForSelection(cell): void

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:503

Parameters​
cell​

TableDOMCell

Returns​

void

$setFocusCellForSelection()​

$setFocusCellForSelection(cell, ignoreStart?): boolean

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:402

Parameters​
cell​

TableDOMCell

ignoreStart?​

boolean = false

Returns​

boolean

$updateTableTableSelection()​

$updateTableTableSelection(selection): void

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:368

Parameters​
selection​

TableSelection | null

Returns​

void

getTable()​

getTable(): TableDOMTable

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:263

Returns​

TableDOMTable

removeListeners()​

removeListeners(): void

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:267

Returns​

void

trackTable()​

trackTable(): void

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:282

Returns​

void


TableRowNode​

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:36

Extends​

Constructors​

Constructor​

new TableRowNode(height?, key?): TableRowNode

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:67

Parameters​
height?​

number | undefined

key?​

string

Returns​

TableRowNode

Overrides​

ElementNode.constructor

Methods​

$config()​

$config(): BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"tablerow"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; importDOM: { tr: () => object; }; }>

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:40

Override this to implement the new static node configuration protocol, this method is called directly on the prototype and must not depend on anything initialized in the constructor. Generally it should be a trivial implementation.

Returns​

BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"tablerow"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; importDOM: { tr: () => object; }; }>

Example​
class MyNode extends TextNode {
$config() {
return this.config('my-node', {extends: TextNode});
}
}
Overrides​

ElementNode.$config

afterCloneFrom()​

afterCloneFrom(prevNode): void

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:52

Perform any state updates on the clone of prevNode that are not already handled by the constructor call in the static clone method. If you have state to update in your clone that is not handled directly by the constructor, it is advisable to override this method but it is required to include a call to super.afterCloneFrom(prevNode) in your implementation. This is only intended to be called by $cloneWithProperties function or via a super call.

Parameters​
prevNode​

this

Returns​

void

Example​
class ClassesTextNode extends TextNode {
// Not shown: static getType, static importJSON, exportJSON, createDOM, updateDOM
__classes = new Set<string>();
static clone(node: ClassesTextNode): ClassesTextNode {
// The inherited TextNode constructor is used here, so
// classes is not set by this method.
return new ClassesTextNode(node.__text, node.__key);
}
afterCloneFrom(node: this): void {
// This calls TextNode.afterCloneFrom and LexicalNode.afterCloneFrom
// for necessary state updates
super.afterCloneFrom(node);
this.__addClasses(node.__classes);
}
// This method is a private implementation detail, it is not
// suitable for the public API because it does not call getWritable
__addClasses(classNames: Iterable<string>): this {
for (const className of classNames) {
this.__classes.add(className);
}
return this;
}
addClass(...classNames: string[]): this {
return this.getWritable().__addClasses(classNames);
}
removeClass(...classNames: string[]): this {
const node = this.getWritable();
for (const className of classNames) {
this.__classes.delete(className);
}
return this;
}
getClasses(): Set<string> {
return this.getLatest().__classes;
}
}
Overrides​

ElementNode.afterCloneFrom

canBeEmpty()​

canBeEmpty(): false

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:118

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:122

Returns​

false

Overrides​

ElementNode.canIndent

createDOM()​

createDOM(config): HTMLElement

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:80

Called during the reconciliation process to determine which nodes to insert into the DOM for this Lexical Node.

This method must return exactly one HTMLElement. Nested elements are not supported.

Do not attempt to update the Lexical EditorState during this phase of the update lifecycle.

Parameters​
config​

EditorConfig

Returns​

HTMLElement

Overrides​

ElementNode.createDOM

exportJSON()​

exportJSON(): SerializedTableRowNode

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:72

Controls how the this node is serialized to JSON. This is important for copy and paste between Lexical editors sharing the same namespace. It's also important if you're serializing to JSON for persistent storage somewhere. See Serialization & Deserialization.

Returns​

SerializedTableRowNode

Overrides​

ElementNode.exportJSON

extractWithChild()​

extractWithChild(child, selection, destination): boolean

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:92

Parameters​
child​

LexicalNode

selection​

BaseSelection | null

destination​

"clone" | "html"

Returns​

boolean

Overrides​

ElementNode.extractWithChild

getHeight()​

getHeight(): number | undefined

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:110

Returns​

number | undefined

isShadowRoot()​

isShadowRoot(): boolean

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:100

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

setHeight()​

setHeight(height?): this

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:104

Parameters​
height?​

number

Returns​

this

updateDOM()​

updateDOM(prevNode): boolean

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:114

Called when a node changes and should update the DOM in whatever way is necessary to make it align with any changes that might have happened during the update.

Returning "true" here will cause lexical to unmount and recreate the DOM node (by calling createDOM). You would need to do this if the element tag changes, for instance.

Parameters​
prevNode​

this

Returns​

boolean

Overrides​

ElementNode.updateDOM

updateFromJSON()​

updateFromJSON(serializedNode): this

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:57

Update this LexicalNode instance from serialized JSON. It's recommended to implement as much logic as possible in this method instead of the static importJSON method, so that the functionality can be inherited in subclasses.

The LexicalUpdateJSON utility type should be used to ignore any type, version, or children properties in the JSON so that the extended JSON from subclasses are acceptable parameters for the super call.

If overridden, this method must call super.

Parameters​
serializedNode​

LexicalUpdateJSON<SerializedTableRowNode>

Returns​

this

Example​
class MyTextNode extends TextNode {
// ...
static importJSON(serializedNode: SerializedMyTextNode): MyTextNode {
return $createMyTextNode()
.updateFromJSON(serializedNode);
}
updateFromJSON(
serializedNode: LexicalUpdateJSON<SerializedMyTextNode>,
): this {
return super.updateFromJSON(serializedNode)
.setMyProperty(serializedNode.myProperty);
}
}
Overrides​

ElementNode.updateFromJSON

Interfaces​

TableCellRectBoundary​

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1164

Properties​

maxColumn​

maxColumn: number

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1167

maxRow​

maxRow: number

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1168

minColumn​

minColumn: number

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1165

minRow​

minRow: number

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1166


TableConfig​

Defined in: packages/lexical-table/src/LexicalTableExtension.ts:40

Properties​

hasCellBackgroundColor​

hasCellBackgroundColor: boolean

Defined in: packages/lexical-table/src/LexicalTableExtension.ts:49

When false (default true), the background color of TableCellNode will always be removed.

hasCellMerge​

hasCellMerge: boolean

Defined in: packages/lexical-table/src/LexicalTableExtension.ts:45

When false (default true), merged cell support (colspan and rowspan) will be disabled and all tables will be forced into a regular grid with 1x1 table cells.

hasHorizontalScroll​

hasHorizontalScroll: boolean

Defined in: packages/lexical-table/src/LexicalTableExtension.ts:57

When true (default true), tables will be wrapped in a <div> to enable horizontal scrolling

hasNestedTables​

hasNestedTables: boolean

Defined in: packages/lexical-table/src/LexicalTableExtension.ts:76

Experimental

When true (default false), nested tables will be allowed.

Nested tables are not officially supported.

hasStickyScrollbar​

hasStickyScrollbar: boolean

Defined in: packages/lexical-table/src/LexicalTableExtension.ts:70

When true (default false), a sticky scrollbar is rendered below each table that overflows horizontally. Requires hasHorizontalScroll to be true. The native scrollbar is hidden via inline scrollbar-width: none (Firefox/Chromium). Themed consumers providing a tableScrollableWrapper class should also add ::-webkit-scrollbar { display: none } for Safari/WebKit. A themed scrollbar is expected to guarantee its own visible height (the playground does this with ::-webkit-scrollbar { height: ... }); the unthemed fallback depends on classic native scrollbars, so on platforms where those render with no thickness (overlay scrollbars, and non-layout environments like jsdom) it is disabled at runtime and the wrapper's native scrollbar is restored.

hasTabHandler​

hasTabHandler: boolean

Defined in: packages/lexical-table/src/LexicalTableExtension.ts:53

When true (default true), the tab key can be used to navigate table cells.


TableSelection​

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:127

Implements​

Properties​

_cachedNodes​

_cachedNodes: LexicalNode[] | null

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:131

Implementation of​

BaseSelection._cachedNodes

anchor​

anchor: PointType

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:129

dirty​

dirty: boolean

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:132

Implementation of​

BaseSelection.dirty

focus​

focus: PointType

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:130

tableKey​

tableKey: string

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:128

Methods​

clone()​

clone(): TableSelection

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:213

Returns​

TableSelection

Implementation of​

BaseSelection.clone

extract()​

extract(): LexicalNode[]

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:225

Returns​

LexicalNode[]

Implementation of​

BaseSelection.extract

getCachedNodes()​

getCachedNodes(): LexicalNode[] | null

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:183

Returns​

LexicalNode[] | null

Implementation of​

BaseSelection.getCachedNodes

getNodes()​

getNodes(): LexicalNode[]

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:332

Returns​

LexicalNode[]

Implementation of​

BaseSelection.getNodes

getShape()​

getShape(): TableSelectionShape

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:293

Returns​

TableSelectionShape

Deprecated​

Use $computeTableMap and $computeTableCellRectBoundary directly.

getStartEndPoints()​

getStartEndPoints(): [PointType, PointType]

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:144

Returns​

[PointType, PointType]

Implementation of​

BaseSelection.getStartEndPoints

getTextContent()​

getTextContent(): string

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:407

Returns​

string

Implementation of​

BaseSelection.getTextContent

hasFormat()​

hasFormat(type): boolean

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:265

Returns whether the provided TextFormatType is present on the Selection. This will be true if any paragraph in table cells has the specified format.

Parameters​
type​

TextFormatType

the TextFormatType to check for.

Returns​

boolean

true if the provided format is currently toggled on the Selection, false otherwise.

insertNodes()​

insertNodes(nodes): void

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:280

Parameters​
nodes​

LexicalNode[]

Returns​

void

Implementation of​

BaseSelection.insertNodes

insertRawText()​

insertRawText(text): void

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:229

Parameters​
text​

string

Returns​

void

Implementation of​

BaseSelection.insertRawText

insertText()​

insertText(): void

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:254

Returns​

void

Implementation of​

BaseSelection.insertText

is()​

is(selection): boolean

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:191

Parameters​
selection​

BaseSelection | null

Returns​

boolean

Implementation of​

BaseSelection.is

isBackward()​

isBackward(): boolean

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:179

Returns whether the Selection is "backwards", meaning the focus logically precedes the anchor in the EditorState.

Returns​

boolean

true if the Selection is backwards, false otherwise.

Implementation of​

BaseSelection.isBackward

isCollapsed()​

isCollapsed(): boolean

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:221

Returns​

boolean

Implementation of​

BaseSelection.isCollapsed

isValid()​

isValid(): boolean

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:155

$createTableSelection unfortunately makes it very easy to create nonsense selections, so we have a method to see if the selection probably makes sense.

Returns​

boolean

true if the TableSelection is (probably) valid

set()​

set(tableKey, anchorCellKey, focusCellKey): void

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:200

Parameters​
tableKey​

string

anchorCellKey​

string

focusCellKey​

string

Returns​

void

setCachedNodes()​

setCachedNodes(nodes): void

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:187

Parameters​
nodes​

LexicalNode[] | null

Returns​

void

Implementation of​

BaseSelection.setCachedNodes

Type Aliases​

HTMLTableElementWithWithTableSelectionState​

HTMLTableElementWithWithTableSelectionState = HTMLTableElement & object

Defined in: packages/lexical-table/src/LexicalTableSelectionHelpers.ts:1367

Type Declaration​

__lexicalTableSelection?​

optional __lexicalTableSelection?: TableObserver


InsertTableCommandPayload​

InsertTableCommandPayload = Readonly<{ columns: string; includeHeaders?: InsertTableCommandPayloadHeaders; rows: string; }>

Defined in: packages/lexical-table/src/LexicalTableCommands.ts:18


InsertTableCommandPayloadHeaders​

InsertTableCommandPayloadHeaders = Readonly<{ columns: boolean; rows: boolean; }> | boolean

Defined in: packages/lexical-table/src/LexicalTableCommands.ts:11


SerializedTableCellNode​

SerializedTableCellNode = Spread<{ backgroundColor?: null | string; colSpan?: number; headerState: TableCellHeaderState; rowSpan?: number; verticalAlign?: string; width?: number; }, SerializedElementNode>

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:43


SerializedTableNode​

SerializedTableNode = Spread<{ colWidths?: readonly number[]; frozenColumnCount?: number; frozenRowCount?: number; rowStriping?: boolean; }, SerializedElementNode>

Defined in: packages/lexical-table/src/LexicalTableNode.ts:57


SerializedTableRowNode​

SerializedTableRowNode = Spread<{ height?: number; }, SerializedElementNode>

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:28


TableDOMCell​

TableDOMCell = object

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:47

Properties​

elem​

elem: HTMLElement

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:48

hasBackgroundColor​

hasBackgroundColor: boolean

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:50

highlighted​

highlighted: boolean

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:49

x​

x: number

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:51

y​

y: number

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:52


TableMapType​

TableMapType = TableMapValueType[][]

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:69


TableMapValueType​

TableMapValueType = object

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:64

Properties​

cell​

cell: TableCellNode

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:65

startColumn​

startColumn: number

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:67

startRow​

startRow: number

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:66


TableSelectionShape​

TableSelectionShape = object

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:57

Properties​

fromX​

fromX: number

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:58

fromY​

fromY: number

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:59

toX​

toX: number

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:60

toY​

toY: number

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:61

Variables​

$deleteTableColumn__EXPERIMENTAL​

const $deleteTableColumn__EXPERIMENTAL: () => void = $deleteTableColumnAtSelection

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:807

Returns​

void

Deprecated​

renamed to $deleteTableColumnAtSelection


$deleteTableRow__EXPERIMENTAL​

const $deleteTableRow__EXPERIMENTAL: () => void = $deleteTableRowAtSelection

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:723

Returns​

void

Deprecated​

renamed to $deleteTableRowAtSelection


$insertTableColumn__EXPERIMENTAL​

const $insertTableColumn__EXPERIMENTAL: (insertAfter) => TableCellNode | null = $insertTableColumnAtSelection

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:490

Inserts a column before or after the current focus cell node, taking into account any spans. If successful, returns the first inserted cell node.

Parameters​

insertAfter?​

boolean = true

Returns​

TableCellNode | null

Deprecated​

renamed to $insertTableColumnAtSelection


$insertTableRow__EXPERIMENTAL​

const $insertTableRow__EXPERIMENTAL: (insertAfter) => TableRowNode | null = $insertTableRowAtSelection

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:307

Inserts a table row before or after the current focus cell node, taking into account any spans. If successful, returns the inserted table row node.

Parameters​

insertAfter?​

boolean = true

Returns​

TableRowNode | null

Deprecated​

renamed to $insertTableRowAtSelection


INSERT_TABLE_COMMAND​

const INSERT_TABLE_COMMAND: LexicalCommand<InsertTableCommandPayload>

Defined in: packages/lexical-table/src/LexicalTableCommands.ts:24


TableCellHeaderStates​

const TableCellHeaderStates: object

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:33

Type Declaration​

BOTH​

BOTH: number = 3

COLUMN​

COLUMN: number = 2

NO_STATUS​

NO_STATUS: number = 0

ROW​

ROW: number = 1


TableExtension​

const TableExtension: LexicalExtension<TableConfig, "@lexical/table/Table", NamedSignalsOutput<TableConfig>, unknown>

Defined in: packages/lexical-table/src/LexicalTableExtension.ts:141

Configures TableNode, TableRowNode, TableCellNode and registers table behaviors (see TableConfig)


TableImportExtension​

const TableImportExtension: LexicalExtension<ExtensionConfigBase, "@lexical/table/Import", unknown, unknown>

Defined in: packages/lexical-table/src/LexicalTableExtension.ts:231

Experimental

Bundles TableImportRules together with the runtime TableExtension.

Deprecated​

TableExtension now registers TableImportRules (and CoreImportExtension) itself — depend on it directly instead.


TableImportRules​

const TableImportRules: (DOMImportRule<ElementSelectorBuilder<HTMLTableElement, Record<string, never>>> | DOMImportRule<ElementSelectorBuilder<HTMLTableCellElement, Record<string, never>>> | DOMImportRule<ElementSelectorBuilder<HTMLTableRowElement, Record<string, never>>>)[]

Defined in: packages/lexical-table/src/TableImportExtension.ts:308

Experimental

Import rules for TableNode, TableRowNode, and TableCellNode.

Registered by TableExtension itself (together with CoreImportExtension), so any editor that uses the table extension can import these tags through the DOMImportExtension pipeline without further configuration.


TableRowSchema​

const TableRowSchema: ChildSchema

Defined in: packages/lexical-table/src/TableImportExtension.ts:292

Experimental

A ChildSchema that enforces TableRowNode invariants: only TableCellNode children are accepted; non-cell children are dropped (the legacy converter does the same via $descendantsMatching).


TableSchema​

const TableSchema: ChildSchema

Defined in: packages/lexical-table/src/TableImportExtension.ts:276

Experimental

A ChildSchema that enforces TableNode invariants: only TableRowNode children are accepted; orphan TableCellNode runs are wrapped in a synthesized row.

Functions​

$computeTableCellRectBoundary()​

$computeTableCellRectBoundary(map, cellAMap, cellBMap): TableCellRectBoundary

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1204

Compute the bounding rectangle of two table cells in a table map, expanding iteratively to include any merged cells that overlap the boundary.

Parameters​

map​

TableMapType

cellAMap​

TableMapValueType

cellBMap​

TableMapValueType

Returns​

TableCellRectBoundary


$computeTableMap()​

$computeTableMap(tableNode, cellA, cellB): [TableMapType, TableMapValueType, TableMapValueType]

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1042

Parameters​

tableNode​

TableNode

cellA​

TableCellNode

cellB​

TableCellNode

Returns​

[TableMapType, TableMapValueType, TableMapValueType]


$computeTableMapSkipCellCheck()​

$computeTableMapSkipCellCheck(tableNode, cellA, cellB): [TableMapType, TableMapValueType | null, TableMapValueType | null]

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1057

Parameters​

tableNode​

TableNode

cellA​

TableCellNode | null

cellB​

TableCellNode | null

Returns​

[TableMapType, TableMapValueType | null, TableMapValueType | null]


$createTableCellNode()​

$createTableCellNode(headerState?, colSpan?, width?): TableCellNode

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:450

Parameters​

headerState?​

number = TableCellHeaderStates.NO_STATUS

colSpan?​

number = 1

width?​

number

Returns​

TableCellNode


$createTableNode()​

$createTableNode(): TableNode

Defined in: packages/lexical-table/src/LexicalTableNode.ts:870

Returns​

TableNode


$createTableNodeWithDimensions()​

$createTableNodeWithDimensions(rowCount, columnCount, includeHeaders?): TableNode

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:52

Parameters​

rowCount​

number

columnCount​

number

includeHeaders?​

InsertTableCommandPayloadHeaders = true

Returns​

TableNode


$createTableRowNode()​

$createTableRowNode(height?): TableRowNode

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:141

Parameters​

height?​

number

Returns​

TableRowNode


$createTableSelection()​

$createTableSelection(): TableSelection

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:426

Returns​

TableSelection

Deprecated​

Use $createTableSelectionFrom instead.


$createTableSelectionFrom()​

$createTableSelectionFrom(tableNode, anchorCell, focusCell): TableSelection

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:441

Creates a TableSelection spanning from anchorCell to focusCell within tableNode. In __DEV__ mode, validates that both cells belong to the given table and that the table is attached to the editor state.

If the current selection is already a TableSelection, it clones and re-targets it (preserving identity for dirty-checking); otherwise it constructs a fresh one.

Parameters​

tableNode​

TableNode

anchorCell​

TableCellNode

focusCell​

TableCellNode

Returns​

TableSelection


$deleteTableColumn()​

$deleteTableColumn(tableNode, targetIndex): TableNode

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:597

Parameters​

tableNode​

TableNode

targetIndex​

number

Returns​

TableNode

Deprecated​

This function does not support merged cells. Use $deleteTableColumnAtSelection instead.


$deleteTableColumnAtSelection()​

$deleteTableColumnAtSelection(): void

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:725

Returns​

void


$deleteTableRowAtSelection()​

$deleteTableRowAtSelection(): void

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:620

Returns​

void


$findCellNode()​

$findCellNode(node): TableCellNode | null

Defined in: packages/lexical-table/src/LexicalTableSelectionHelpers.ts:1963

Parameters​

node​

LexicalNode

Returns​

TableCellNode | null


$findTableNode()​

$findTableNode(node): TableNode | null

Defined in: packages/lexical-table/src/LexicalTableSelectionHelpers.ts:1968

Parameters​

node​

LexicalNode

Returns​

TableNode | null


$getElementForTableNode()​

$getElementForTableNode(editor, tableNode): TableDOMTable

Defined in: packages/lexical-table/src/LexicalTableNode.ts:820

Parameters​

editor​

LexicalEditor

tableNode​

TableNode

Returns​

TableDOMTable


$getNodeTriplet()​

$getNodeTriplet(source): [TableCellNode, TableRowNode, TableNode]

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1130

Parameters​

source​

LexicalNode | PointType | TableCellNode

Returns​

[TableCellNode, TableRowNode, TableNode]


$getTableAndElementByKey()​

$getTableAndElementByKey(tableNodeKey, editor?): object

Defined in: packages/lexical-table/src/LexicalTableObserver.ts:63

Parameters​

tableNodeKey​

string

editor?​

LexicalEditor = ...

Returns​

object

tableElement​

tableElement: HTMLTableElementWithWithTableSelectionState

tableNode​

tableNode: TableNode


$getTableCellNodeFromLexicalNode()​

$getTableCellNodeFromLexicalNode(startingNode): TableCellNode | null

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:94

Parameters​

startingNode​

LexicalNode

Returns​

TableCellNode | null


$getTableCellNodeRect()​

$getTableCellNodeRect(tableCellNode): { colSpan: number; columnIndex: number; rowIndex: number; rowSpan: number; } | null

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1390

Parameters​

tableCellNode​

TableCellNode

Returns​

{ colSpan: number; columnIndex: number; rowIndex: number; rowSpan: number; } | null


$getTableColumnIndexFromTableCellNode()​

$getTableColumnIndexFromTableCellNode(tableCellNode): number

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:138

Parameters​

tableCellNode​

TableCellNode

Returns​

number


$getTableNodeFromLexicalNodeOrThrow()​

$getTableNodeFromLexicalNodeOrThrow(startingNode): TableNode

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:118

Parameters​

startingNode​

LexicalNode

Returns​

TableNode


$getTableRowIndexFromTableCellNode()​

$getTableRowIndexFromTableCellNode(tableCellNode): number

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:130

Parameters​

tableCellNode​

TableCellNode

Returns​

number


$getTableRowNodeFromTableCellNodeOrThrow()​

$getTableRowNodeFromTableCellNodeOrThrow(startingNode): TableRowNode

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:106

Parameters​

startingNode​

LexicalNode

Returns​

TableRowNode


$insertTableColumn()​

$insertTableColumn(tableNode, targetIndex, shouldInsertAfter?, columnCount, table): TableNode

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:388

Parameters​

tableNode​

TableNode

targetIndex​

number

shouldInsertAfter?​

boolean = true

columnCount​

number

table​

TableDOMTable

Returns​

TableNode

Deprecated​

This function does not support merged cells. Use $insertTableColumnAtSelection or $insertTableColumnAtNode instead.


$insertTableColumnAtNode()​

$insertTableColumnAtNode(cellNode, insertAfter?, shouldSetSelection?): TableCellNode | null

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:497

Inserts a column before or after the given cell node, taking into account any spans. If successful, returns the first inserted cell node.

Parameters​

cellNode​

TableCellNode

insertAfter?​

boolean = true

shouldSetSelection?​

boolean = true

Returns​

TableCellNode | null


$insertTableColumnAtSelection()​

$insertTableColumnAtSelection(insertAfter?): TableCellNode | null

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:452

Inserts a column before or after the current focus cell node, taking into account any spans. If successful, returns the first inserted cell node.

Parameters​

insertAfter?​

boolean = true

Returns​

TableCellNode | null


$insertTableRow()​

$insertTableRow(tableNode, targetIndex, shouldInsertAfter?, rowCount, table): TableNode

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:184

Parameters​

tableNode​

TableNode

targetIndex​

number

shouldInsertAfter?​

boolean = true

rowCount​

number

table​

TableDOMTable

Returns​

TableNode

Deprecated​

This function does not support merged cells. Use $insertTableRowAtSelection or $insertTableRowAtNode instead.


$insertTableRowAtNode()​

$insertTableRowAtNode(cellNode, insertAfter?): TableRowNode | null

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:314

Inserts a table row before or after the given cell node, taking into account any spans. If successful, returns the inserted table row node.

Parameters​

cellNode​

TableCellNode

insertAfter?​

boolean = true

Returns​

TableRowNode | null


$insertTableRowAtSelection()​

$insertTableRowAtSelection(insertAfter?): TableRowNode | null

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:269

Inserts a table row before or after the current focus cell node, taking into account any spans. If successful, returns the inserted table row node.

Parameters​

insertAfter?​

boolean = true

Returns​

TableRowNode | null


$isScrollableTablesActive()​

$isScrollableTablesActive(editor?): boolean

Defined in: packages/lexical-table/src/LexicalTableNode.ts:332

Parameters​

editor?​

LexicalEditor = ...

Returns​

boolean


$isSimpleTable()​

$isSimpleTable(table): boolean

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1283

Checks if the table does not have any merged cells.

Parameters​

table​

TableNode

Table to check for if it has any merged cells.

Returns​

boolean

True if the table does not have any merged cells, false otherwise.


$isStickyScrollbarActive()​

$isStickyScrollbarActive(editor?): boolean

Defined in: packages/lexical-table/src/LexicalTableNode.ts:338

Parameters​

editor?​

LexicalEditor = ...

Returns​

boolean


$isTableCellNode()​

$isTableCellNode(node): node is TableCellNode

Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:458

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is TableCellNode


$isTableNode()​

$isTableNode(node): node is TableNode

Defined in: packages/lexical-table/src/LexicalTableNode.ts:874

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is TableNode


$isTableRowNode()​

$isTableRowNode(node): node is TableRowNode

Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:145

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is TableRowNode


$isTableSelection()​

$isTableSelection(x): x is TableSelection

Defined in: packages/lexical-table/src/LexicalTableSelection.ts:421

Type guard for TableSelection.

Parameters​

x​

unknown

Returns​

x is TableSelection


$mergeCells()​

$mergeCells(cellNodes): TableCellNode | null

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:827

Parameters​

cellNodes​

TableCellNode[]

Returns​

TableCellNode | null


$moveTableColumn()​

$moveTableColumn(tableNode, originColumn, targetColumn): void

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1317

Moves a column from one position to another within a simple (non-merged) table.

Parameters​

tableNode​

TableNode

The table node to modify.

originColumn​

number

The index of the column to move.

targetColumn​

number

The index to move the column to.

Returns​

void


$moveTableRow()​

$moveTableRow(tableNode, originRow, targetRow): void

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1360

Moves a row from one position to another within a simple (non-merged) table.

Parameters​

tableNode​

TableNode

The table node to modify.

originRow​

number

The index of the row to move.

targetRow​

number

The index to move the row to.

Returns​

void


$removeTableRowAtIndex()​

$removeTableRowAtIndex(tableNode, indexToDelete): TableNode

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:166

Parameters​

tableNode​

TableNode

indexToDelete​

number

Returns​

TableNode


$setTableColumnIsHeader()​

$setTableColumnIsHeader(tableNode, columnIndex, isHeader): void

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1649

Parameters​

tableNode​

TableNode

columnIndex​

number

isHeader​

boolean

Returns​

void


$setTableRowIsHeader()​

$setTableRowIsHeader(tableNode, rowIndex, isHeader): void

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1621

Parameters​

tableNode​

TableNode

rowIndex​

number

isHeader​

boolean

Returns​

void


$unmergeCell()​

$unmergeCell(): void

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:936

Returns​

void


$unmergeCellNode()​

$unmergeCellNode(cellNode): void

Defined in: packages/lexical-table/src/LexicalTableUtils.ts:958

Unmerges the given cell, splitting it back into individual cells. Unlike $unmergeCell, this does not depend on the current selection. No-op if the cell is not merged.

Parameters​

cellNode​

TableCellNode

The merged cell to split.

Returns​

void


applyTableHandlers()​

applyTableHandlers(tableNode, element, editor, hasTabHandler, tableObservers): TableObserver

Defined in: packages/lexical-table/src/LexicalTableSelectionHelpers.ts:594

Parameters​

tableNode​

TableNode

element​

HTMLElement

editor​

LexicalEditor

hasTabHandler​

boolean

tableObservers​

TableObservers

Returns​

TableObserver


getDOMCellFromTarget()​

getDOMCellFromTarget(node): TableDOMCell | null

Defined in: packages/lexical-table/src/LexicalTableSelectionHelpers.ts:1426

Parameters​

node​

Node | null

Returns​

TableDOMCell | null


getTableElement()​

getTableElement<T>(tableNode, dom): HTMLTableElementWithWithTableSelectionState | T & null

Defined in: packages/lexical-table/src/LexicalTableSelectionHelpers.ts:160

Type Parameters​

T​

T extends HTMLElement | null

Parameters​

tableNode​

TableNode

dom​

T

Returns​

HTMLTableElementWithWithTableSelectionState | T & null


getTableObserverFromTableElement()​

getTableObserverFromTableElement(tableElement): TableObserver | null

Defined in: packages/lexical-table/src/LexicalTableSelectionHelpers.ts:1391

Parameters​

tableElement​

HTMLTableElementWithWithTableSelectionState

Returns​

TableObserver | null


registerTableCellUnmergeTransform()​

registerTableCellUnmergeTransform(editor): () => void

Defined in: packages/lexical-table/src/LexicalTablePluginHelpers.ts:264

Register a transform to ensure that all TableCellNode have a colSpan and rowSpan of 1. This should only be registered when you do not want to support merged cells.

Parameters​

editor​

LexicalEditor

The editor

Returns​

An unregister callback

() => void


registerTablePlugin()​

registerTablePlugin(editor, options?): () => void

Defined in: packages/lexical-table/src/LexicalTablePluginHelpers.ts:390

Register table command listeners and the table integrity transforms. The table selection observer should be registered separately after this with registerTableSelectionObserver.

Parameters​

editor​

LexicalEditor

The editor

options?​

Pick<NamedSignalsOutput<TableConfig>, "hasNestedTables">

Returns​

An unregister callback

() => void


registerTableSelectionObserver()​

registerTableSelectionObserver(editor, hasTabHandler?): () => void

Defined in: packages/lexical-table/src/LexicalTablePluginHelpers.ts:319

Parameters​

editor​

LexicalEditor

hasTabHandler?​

boolean = true

Returns​

() => void


setScrollableTablesActive()​

setScrollableTablesActive(editor, active): void

Defined in: packages/lexical-table/src/LexicalTableNode.ts:354

Parameters​

editor​

LexicalEditor

active​

boolean

Returns​

void