Skip to main content

@lexical/table

Classes​

TableCellNode​

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

Extends​

Constructors​

Constructor​

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

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

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">

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

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">

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:88

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:302

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

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

Returns​

false

Overrides​

ElementNode.canIndent

collapseAtStart()​

collapseAtStart(): true

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

Returns​

true

Overrides​

ElementNode.collapseAtStart

createDOM()​

createDOM(config): HTMLTableCellElement

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

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:154

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:182

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:243

Returns​

string | null

getColSpan()​

getColSpan(): number

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

Returns​

number

getHeaderStyles()​

getHeaderStyles(): number

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

Returns​

number

getRowSpan()​

getRowSpan(): number

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

Returns​

number

getTag()​

getTag(): "td" | "th"

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

Returns​

"td" | "th"

getVerticalAlign()​

getVerticalAlign(): string | undefined

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

Returns​

string | undefined

getWidth()​

getWidth(): number | undefined

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

Returns​

number | undefined

hasHeader()​

hasHeader(): boolean

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

Returns​

boolean

hasHeaderState()​

hasHeaderState(headerState): boolean

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

Parameters​
headerState​

number

Returns​

boolean

isShadowRoot()​

isShadowRoot(): boolean

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

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

setBackgroundColor()​

setBackgroundColor(newBackgroundColor): this

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

Parameters​
newBackgroundColor​

string | null

Returns​

this

setColSpan()​

setColSpan(colSpan): this

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

Parameters​
colSpan​

number

Returns​

this

setHeaderStyles()​

setHeaderStyles(headerState, mask?): this

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

Parameters​
headerState​

number

mask?​

number = TableCellHeaderStates.BOTH

Returns​

this

setRowSpan()​

setRowSpan(rowSpan): this

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

Parameters​
rowSpan​

number

Returns​

this

setVerticalAlign()​

setVerticalAlign(newVerticalAlign): this

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

Parameters​
newVerticalAlign​

string | null | undefined

Returns​

this

setWidth()​

setWidth(width): this

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

Parameters​
width​

number | undefined

Returns​

this

toggleHeaderStyle()​

toggleHeaderStyle(headerStateToToggle): this

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

Parameters​
headerStateToToggle​

number

Returns​

this

updateDOM()​

updateDOM(prevNode): boolean

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

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:98

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:176

Extends​

Properties​

__colWidths?​

optional __colWidths?: readonly number[]

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

__frozenColumnCount​

__frozenColumnCount: number = 0

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

__frozenRowCount​

__frozenRowCount: number = 0

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

Methods​

$config()​

$config(): BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"table">

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

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">

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:208

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:438

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

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

Returns​

false

Overrides​

ElementNode.canIndent

canSelectBefore()​

canSelectBefore(): true

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

Returns​

true

createDOM()​

createDOM(config, editor?): HTMLElement

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

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:356

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:225

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:237

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:513

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableCellNode | null

getCellNodeFromCordsOrThrow()​

getCellNodeFromCordsOrThrow(x, y, table): TableCellNode

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

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableCellNode

getColumnCount()​

getColumnCount(): number

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

Returns​

number

getColWidths()​

getColWidths(): readonly number[] | undefined

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

Returns​

readonly number[] | undefined

getCordsFromCellNode()​

getCordsFromCellNode(tableCellNode, table): object

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

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:475

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableDOMCell | null

getDOMCellFromCordsOrThrow()​

getDOMCellFromCordsOrThrow(x, y, table): TableDOMCell

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

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableDOMCell

getDOMSlot()​

getDOMSlot(element): ElementDOMSlot<HTMLTableElement>

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

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:563

Returns​

number

getFrozenRows()​

getFrozenRows(): number

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

Returns​

number

getRowStriping()​

getRowStriping(): boolean

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

Returns​

boolean

isShadowRoot()​

isShadowRoot(): boolean

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

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

scaleDOMColWidths()​

scaleDOMColWidths(dom, scale): void

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

Parameters​
dom​

HTMLElement

scale​

number

Returns​

void

setColWidths()​

setColWidths(colWidths): this

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

Parameters​
colWidths​

readonly number[] | undefined

Returns​

this

setFrozenColumns()​

setFrozenColumns(columnCount): this

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

Parameters​
columnCount​

number

Returns​

this

setFrozenRows()​

setFrozenRows(rowCount): this

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

Parameters​
rowCount​

number

Returns​

this

setRowStriping()​

setRowStriping(newRowStriping): this

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

Parameters​
newRowStriping​

boolean

Returns​

this

updateDOM()​

updateDOM(prevNode, dom, config): boolean

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

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:216

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:305

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:284

Parameters​
prevNode​

TableNode | null

tableWrapper​

HTMLDivElement

tableElement​

HTMLTableElement

config​

EditorConfig

Returns​

void


TableObserver​

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

Constructors​

Constructor​

new TableObserver(editor, tableNodeKey): TableObserver

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

Parameters​
editor​

LexicalEditor

tableNodeKey​

string

Returns​

TableObserver

Properties​

abortController​

abortController: AbortController

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

anchorCell​

anchorCell: TableDOMCell | null

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

anchorCellNodeKey​

anchorCellNodeKey: string | null

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

anchorX​

anchorX: number

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

anchorY​

anchorY: number

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

editor​

editor: LexicalEditor

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

focusCell​

focusCell: TableDOMCell | null

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

focusCellNodeKey​

focusCellNodeKey: string | null

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

focusX​

focusX: number

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

focusY​

focusY: number

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

hasHijackedSelectionStyles​

hasHijackedSelectionStyles: boolean

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

isHighlightingCells​

isHighlightingCells: boolean

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

isSelecting​

isSelecting: boolean

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

listenerOptions​

listenerOptions: object

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

signal​

signal: AbortSignal

listenersToRemove​

listenersToRemove: Set<() => void>

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

pointerType​

pointerType: string | null

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

table​

table: TableDOMTable

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

tableNodeKey​

tableNodeKey: string

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

tableSelection​

tableSelection: TableSelection | null

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

Methods​

$clearHighlight()​

$clearHighlight(setEmptySelection?): void

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

Parameters​
setEmptySelection?​

boolean = true

Returns​

void

$clearText()​

$clearText(): void

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

Returns​

void

$disableHighlightStyle()​

$disableHighlightStyle(): void

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

Returns​

void

$enableHighlightStyle()​

$enableHighlightStyle(): void

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

Returns​

void

$formatCells()​

$formatCells(type): void

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

Parameters​
type​

TextFormatType

Returns​

void

$getAnchorTableCell()​

$getAnchorTableCell(): TableCellNode | null

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

Returns​

TableCellNode | null

$getAnchorTableCellOrThrow()​

$getAnchorTableCellOrThrow(): TableCellNode

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

Returns​

TableCellNode

$getFocusTableCell()​

$getFocusTableCell(): TableCellNode | null

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

Returns​

TableCellNode | null

$getFocusTableCellOrThrow()​

$getFocusTableCellOrThrow(): TableCellNode

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

Returns​

TableCellNode

$lookup()​

$lookup(): object

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

Returns​

object

tableElement​

tableElement: HTMLTableElementWithWithTableSelectionState

tableNode​

tableNode: TableNode

$setAnchorCellForSelection()​

$setAnchorCellForSelection(cell): void

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

Parameters​
cell​

TableDOMCell

Returns​

void

$setFocusCellForSelection()​

$setFocusCellForSelection(cell, ignoreStart?): boolean

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

Parameters​
cell​

TableDOMCell

ignoreStart?​

boolean = false

Returns​

boolean

$updateTableTableSelection()​

$updateTableTableSelection(selection): void

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

Parameters​
selection​

TableSelection | null

Returns​

void

getTable()​

getTable(): TableDOMTable

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

Returns​

TableDOMTable

removeListeners()​

removeListeners(): void

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

Returns​

void

trackTable()​

trackTable(): void

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

Returns​

void


TableRowNode​

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

Extends​

Constructors​

Constructor​

new TableRowNode(height?, key?): TableRowNode

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

Parameters​
height?​

number | undefined

key?​

string

Returns​

TableRowNode

Overrides​

ElementNode.constructor

Methods​

$config()​

$config(): BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"tablerow">

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

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">

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:49

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:115

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

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

Returns​

false

Overrides​

ElementNode.canIndent

createDOM()​

createDOM(config): HTMLElement

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

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:69

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:89

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:107

Returns​

number | undefined

isShadowRoot()​

isShadowRoot(): boolean

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

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

setHeight()​

setHeight(height?): this

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

Parameters​
height?​

number

Returns​

this

updateDOM()​

updateDOM(prevNode): boolean

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

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:54

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​

TableConfig​

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

Properties​

hasCellBackgroundColor​

hasCellBackgroundColor: boolean

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

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

hasCellMerge​

hasCellMerge: boolean

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

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:43

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:49

Experimental

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

Nested tables are not officially supported.

hasTabHandler​

hasTabHandler: boolean

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

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


TableSelection​

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

Implements​

Properties​

_cachedNodes​

_cachedNodes: LexicalNode[] | null

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

Implementation of​

BaseSelection._cachedNodes

anchor​

anchor: PointType

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

dirty​

dirty: boolean

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

Implementation of​

BaseSelection.dirty

focus​

focus: PointType

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

tableKey​

tableKey: string

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

Methods​

clone()​

clone(): TableSelection

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

Returns​

TableSelection

Implementation of​

BaseSelection.clone

extract()​

extract(): LexicalNode[]

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

Returns​

LexicalNode[]

Implementation of​

BaseSelection.extract

getCachedNodes()​

getCachedNodes(): LexicalNode[] | null

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

Returns​

LexicalNode[] | null

Implementation of​

BaseSelection.getCachedNodes

getNodes()​

getNodes(): LexicalNode[]

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

Returns​

LexicalNode[]

Implementation of​

BaseSelection.getNodes

getShape()​

getShape(): TableSelectionShape

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

Returns​

TableSelectionShape

getStartEndPoints()​

getStartEndPoints(): [PointType, PointType]

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

Returns​

[PointType, PointType]

Implementation of​

BaseSelection.getStartEndPoints

getTextContent()​

getTextContent(): string

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

Returns​

string

Implementation of​

BaseSelection.getTextContent

hasFormat()​

hasFormat(type): boolean

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

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 on the Selection, false otherwise.

insertNodes()​

insertNodes(nodes): void

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

Parameters​
nodes​

LexicalNode[]

Returns​

void

Implementation of​

BaseSelection.insertNodes

insertRawText()​

insertRawText(text): void

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

Parameters​
text​

string

Returns​

void

Implementation of​

BaseSelection.insertRawText

insertText()​

insertText(): void

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

Returns​

void

Implementation of​

BaseSelection.insertText

is()​

is(selection): boolean

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

Parameters​
selection​

BaseSelection | null

Returns​

boolean

Implementation of​

BaseSelection.is

isBackward()​

isBackward(): boolean

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

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:205

Returns​

boolean

Implementation of​

BaseSelection.isCollapsed

isValid()​

isValid(): boolean

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

$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:184

Parameters​
tableKey​

string

anchorCellKey​

string

focusCellKey​

string

Returns​

void

setCachedNodes()​

setCachedNodes(nodes): void

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

Parameters​
nodes​

LexicalNode[] | null

Returns​

void

Implementation of​

BaseSelection.setCachedNodes

Type Aliases​

HTMLTableElementWithWithTableSelectionState​

HTMLTableElementWithWithTableSelectionState = HTMLTableElement & object

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

Type Declaration​

__lexicalTableSelection?​

optional __lexicalTableSelection?: TableObserver


InsertTableCommandPayload​

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

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


InsertTableCommandPayloadHeaders​

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

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


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:45


SerializedTableNode​

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

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


SerializedTableRowNode​

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

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


TableDOMCell​

TableDOMCell = object

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

Properties​

elem​

elem: HTMLElement

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

hasBackgroundColor​

hasBackgroundColor: boolean

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

highlighted​

highlighted: boolean

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

x​

x: number

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

y​

y: number

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


TableMapType​

TableMapType = TableMapValueType[][]

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


TableMapValueType​

TableMapValueType = object

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

Properties​

cell​

cell: TableCellNode

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

startColumn​

startColumn: number

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

startRow​

startRow: number

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


TableSelectionShape​

TableSelectionShape = object

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

Properties​

fromX​

fromX: number

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

fromY​

fromY: number

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

toX​

toX: number

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

toY​

toY: number

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

Variables​

$deleteTableColumn__EXPERIMENTAL​

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

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

Returns​

void

Deprecated​

renamed to $deleteTableColumnAtSelection


$deleteTableRow__EXPERIMENTAL​

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

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

Returns​

void

Deprecated​

renamed to $deleteTableRowAtSelection


$insertTableColumn__EXPERIMENTAL​

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

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

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:295

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:26


TableCellHeaderStates​

const TableCellHeaderStates: object

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

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:56

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/TableImportExtension.ts:318

Experimental

Bundles TableImportRules together with the runtime TableExtension. The application is expected to already have CoreImportExtension (or some equivalent) in its dependency graph — the core/text/paragraph/inline-format rules are a shared baseline, not something this leaf importer should re-declare.


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:307

Experimental

Import rules for TableNode, TableRowNode, and TableCellNode.


TableRowSchema​

const TableRowSchema: ChildSchema

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

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:280

Experimental

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

Functions​

$computeTableMap()​

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

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

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:1040

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:452

Parameters​

headerState?​

number = TableCellHeaderStates.NO_STATUS

colSpan?​

number = 1

width?​

number

Returns​

TableCellNode


$createTableNode()​

$createTableNode(): TableNode

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

Returns​

TableNode


$createTableNodeWithDimensions()​

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

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

Parameters​

rowCount​

number

columnCount​

number

includeHeaders?​

InsertTableCommandPayloadHeaders = true

Returns​

TableNode


$createTableRowNode()​

$createTableRowNode(height?): TableRowNode

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

Parameters​

height?​

number

Returns​

TableRowNode


$createTableSelection()​

$createTableSelection(): TableSelection

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

Returns​

TableSelection


$createTableSelectionFrom()​

$createTableSelectionFrom(tableNode, anchorCell, focusCell): TableSelection

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

Parameters​

tableNode​

TableNode

anchorCell​

TableCellNode

focusCell​

TableCellNode

Returns​

TableSelection


$deleteTableColumn()​

$deleteTableColumn(tableNode, targetIndex): TableNode

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

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:715

Returns​

void


$deleteTableRowAtSelection()​

$deleteTableRowAtSelection(): void

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

Returns​

void


$findCellNode()​

$findCellNode(node): TableCellNode | null

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

Parameters​

node​

LexicalNode

Returns​

TableCellNode | null


$findTableNode()​

$findTableNode(node): TableNode | null

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

Parameters​

node​

LexicalNode

Returns​

TableNode | null


$getElementForTableNode()​

$getElementForTableNode(editor, tableNode): TableDOMTable

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

Parameters​

editor​

LexicalEditor

tableNode​

TableNode

Returns​

TableDOMTable


$getNodeTriplet()​

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

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

Parameters​

source​

LexicalNode | PointType | TableCellNode

Returns​

[TableCellNode, TableRowNode, TableNode]


$getTableAndElementByKey()​

$getTableAndElementByKey(tableNodeKey, editor?): object

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

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:82

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:1332

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:126

Parameters​

tableCellNode​

TableCellNode

Returns​

number


$getTableNodeFromLexicalNodeOrThrow()​

$getTableNodeFromLexicalNodeOrThrow(startingNode): TableNode

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

Parameters​

startingNode​

LexicalNode

Returns​

TableNode


$getTableRowIndexFromTableCellNode()​

$getTableRowIndexFromTableCellNode(tableCellNode): number

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

Parameters​

tableCellNode​

TableCellNode

Returns​

number


$getTableRowNodeFromTableCellNodeOrThrow()​

$getTableRowNodeFromTableCellNodeOrThrow(startingNode): TableRowNode

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

Parameters​

startingNode​

LexicalNode

Returns​

TableRowNode


$insertTableColumn()​

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

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

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.


$insertTableColumnAtSelection()​

$insertTableColumnAtSelection(insertAfter?): TableCellNode | null

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

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:172

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.


$insertTableRowAtSelection()​

$insertTableRowAtSelection(insertAfter?): TableRowNode | null

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

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:153

Parameters​

editor?​

LexicalEditor = ...

Returns​

boolean


$isSimpleTable()​

$isSimpleTable(table): boolean

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

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.


$isTableCellNode()​

$isTableCellNode(node): node is TableCellNode

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

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is TableCellNode


$isTableNode()​

$isTableNode(node): node is TableNode

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

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is TableNode


$isTableRowNode()​

$isTableRowNode(node): node is TableRowNode

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

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is TableRowNode


$isTableSelection()​

$isTableSelection(x): x is TableSelection

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

Parameters​

x​

unknown

Returns​

x is TableSelection


$mergeCells()​

$mergeCells(cellNodes): TableCellNode | null

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

Parameters​

cellNodes​

TableCellNode[]

Returns​

TableCellNode | null


$moveTableColumn()​

$moveTableColumn(tableNode, originColumn, targetColumn): void

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

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


$removeTableRowAtIndex()​

$removeTableRowAtIndex(tableNode, indexToDelete): TableNode

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

Parameters​

tableNode​

TableNode

indexToDelete​

number

Returns​

TableNode


$unmergeCell()​

$unmergeCell(): void

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

Returns​

void


applyTableHandlers()​

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

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

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:1202

Parameters​

node​

Node | null

Returns​

TableDOMCell | null


getTableElement()​

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

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

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:1167

Parameters​

tableElement​

HTMLTableElementWithWithTableSelectionState

Returns​

TableObserver | null


registerTableCellUnmergeTransform()​

registerTableCellUnmergeTransform(editor): () => void

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

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:402

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:322

Parameters​

editor​

LexicalEditor

hasTabHandler?​

boolean = true

Returns​

() => void


setScrollableTablesActive()​

setScrollableTablesActive(editor, active): void

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

Parameters​

editor​

LexicalEditor

active​

boolean

Returns​

void