Skip to main content

@lexical/table

Classes​

TableCellNode​

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

Extends​

Constructors​

Constructor​

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

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

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

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

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

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

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

Returns​

false

Overrides​

ElementNode.canIndent

collapseAtStart()​

collapseAtStart(): true

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

Returns​

true

Overrides​

ElementNode.collapseAtStart

createDOM()​

createDOM(config): HTMLTableCellElement

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

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

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

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

Returns​

string | null

getColSpan()​

getColSpan(): number

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

Returns​

number

getHeaderStyles()​

getHeaderStyles(): number

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

Returns​

number

getRowSpan()​

getRowSpan(): number

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

Returns​

number

getTag()​

getTag(): "td" | "th"

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

Returns​

"td" | "th"

getVerticalAlign()​

getVerticalAlign(): string | undefined

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

Returns​

string | undefined

getWidth()​

getWidth(): number | undefined

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

Returns​

number | undefined

hasHeader()​

hasHeader(): boolean

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

Returns​

boolean

hasHeaderState()​

hasHeaderState(headerState): boolean

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

Parameters​
headerState​

number

Returns​

boolean

isShadowRoot()​

isShadowRoot(): boolean

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

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

setBackgroundColor()​

setBackgroundColor(newBackgroundColor): this

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

Parameters​
newBackgroundColor​

string | null

Returns​

this

setColSpan()​

setColSpan(colSpan): this

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

Parameters​
colSpan​

number

Returns​

this

setHeaderStyles()​

setHeaderStyles(headerState, mask?): this

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

Parameters​
headerState​

number

mask?​

number = TableCellHeaderStates.BOTH

Returns​

this

setRowSpan()​

setRowSpan(rowSpan): this

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

Parameters​
rowSpan​

number

Returns​

this

setVerticalAlign()​

setVerticalAlign(newVerticalAlign): this

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

Parameters​
newVerticalAlign​

string | null | undefined

Returns​

this

setWidth()​

setWidth(width): this

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

Parameters​
width​

number | undefined

Returns​

this

toggleHeaderStyle()​

toggleHeaderStyle(headerStateToToggle): this

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

Parameters​
headerStateToToggle​

number

Returns​

this

updateDOM()​

updateDOM(prevNode): boolean

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

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

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

Extends​

Properties​

__colWidths​

__colWidths: readonly number[] | undefined = undefined

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

__frozenColumnCount​

__frozenColumnCount: number = 0

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

__frozenRowCount​

__frozenRowCount: number = 0

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

Methods​

$config()​

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

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

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

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

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

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

Returns​

false

Overrides​

ElementNode.canIndent

canSelectBefore()​

canSelectBefore(): true

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

Returns​

true

createDOM()​

createDOM(config, editor?): HTMLElement

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

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

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

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

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

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableCellNode | null

getCellNodeFromCordsOrThrow()​

getCellNodeFromCordsOrThrow(x, y, table): TableCellNode

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

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableCellNode

getColumnCount()​

getColumnCount(): number

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

Returns​

number

getColWidths()​

getColWidths(): readonly number[] | undefined

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

Returns​

readonly number[] | undefined

getCordsFromCellNode()​

getCordsFromCellNode(tableCellNode, table): object

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

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

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableDOMCell | null

getDOMCellFromCordsOrThrow()​

getDOMCellFromCordsOrThrow(x, y, table): TableDOMCell

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

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableDOMCell

getDOMSlot()​

getDOMSlot(element): ElementDOMSlot<HTMLTableElement>

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

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

Returns​

number

getFrozenRows()​

getFrozenRows(): number

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

Returns​

number

getRowStriping()​

getRowStriping(): boolean

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

Returns​

boolean

isShadowRoot()​

isShadowRoot(): boolean

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

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

scaleDOMColWidths()​

scaleDOMColWidths(dom, scale): void

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

Parameters​
dom​

HTMLElement

scale​

number

Returns​

void

setColWidths()​

setColWidths(colWidths): this

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

Parameters​
colWidths​

readonly number[] | undefined

Returns​

this

setFrozenColumns()​

setFrozenColumns(columnCount): this

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

Parameters​
columnCount​

number

Returns​

this

setFrozenRows()​

setFrozenRows(rowCount): this

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

Parameters​
rowCount​

number

Returns​

this

setRowStriping()​

setRowStriping(newRowStriping): this

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

Parameters​
newRowStriping​

boolean

Returns​

this

updateDOM()​

updateDOM(prevNode, dom, config): boolean

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

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

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

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

Parameters​
prevNode​

TableNode | null

tableWrapper​

HTMLDivElement

tableElement​

HTMLTableElement

config​

EditorConfig

Returns​

void


TableObserver​

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

Constructors​

Constructor​

new TableObserver(editor, tableNodeKey): TableObserver

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

Parameters​
editor​

LexicalEditor

tableNodeKey​

string

Returns​

TableObserver

Properties​

abortController​

abortController: AbortController

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

anchorCell​

anchorCell: TableDOMCell | null

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

anchorCellNodeKey​

anchorCellNodeKey: string | null

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

anchorX​

anchorX: number

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

anchorY​

anchorY: number

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

editor​

editor: LexicalEditor

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

focusCell​

focusCell: TableDOMCell | null

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

focusCellNodeKey​

focusCellNodeKey: string | null

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

focusX​

focusX: number

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

focusY​

focusY: number

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

hasHijackedSelectionStyles​

hasHijackedSelectionStyles: boolean

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

isHighlightingCells​

isHighlightingCells: boolean

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

isPointerDrag​

isPointerDrag: boolean

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

Whether the pointer gesture currently in progress has travelled beyond the tap slop box, i.e. it is a drag rather than a tap. Only a drag may start a table selection from touch input. Set by the pointermove handler and reset whenever the gesture ends.

isSelecting​

isSelecting: boolean

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

listenerOptions​

listenerOptions: object

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

signal​

signal: AbortSignal

listenersToRemove​

listenersToRemove: Set<() => void>

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

pointerStartCell​

pointerStartCell: TableDOMCell | null

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

The cell the pointer gesture currently in progress started on, null when no gesture is in progress. A drag that never leaves this cell is selecting text within it, not selecting cells.

pointerType​

pointerType: string | null

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

table​

table: TableDOMTable

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

tableNodeKey​

tableNodeKey: string

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

tableSelection​

tableSelection: TableSelection | null

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

Methods​

$clearHighlight()​

$clearHighlight(setEmptySelection?): void

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

Parameters​
setEmptySelection?​

boolean = true

Returns​

void

$clearText()​

$clearText(): void

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

Returns​

void

$disableHighlightStyle()​

$disableHighlightStyle(): void

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

Returns​

void

$enableHighlightStyle()​

$enableHighlightStyle(): void

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

Returns​

void

$formatCells()​

$formatCells(type): void

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

Parameters​
type​

TextFormatType

Returns​

void

$getAnchorTableCell()​

$getAnchorTableCell(): TableCellNode | null

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

Returns​

TableCellNode | null

$getAnchorTableCellOrThrow()​

$getAnchorTableCellOrThrow(): TableCellNode

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

Returns​

TableCellNode

$getFocusTableCell()​

$getFocusTableCell(): TableCellNode | null

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

Returns​

TableCellNode | null

$getFocusTableCellOrThrow()​

$getFocusTableCellOrThrow(): TableCellNode

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

Returns​

TableCellNode

$lookup()​

$lookup(): object

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

Returns​

object

tableElement​

tableElement: HTMLTableElementWithWithTableSelectionState

tableNode​

tableNode: TableNode

$setAnchorCellForSelection()​

$setAnchorCellForSelection(cell): void

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

Parameters​
cell​

TableDOMCell

Returns​

void

$setFocusCellForSelection()​

$setFocusCellForSelection(cell, ignoreStart?): boolean

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

Parameters​
cell​

TableDOMCell

ignoreStart?​

boolean = false

Returns​

boolean

$updateTableTableSelection()​

$updateTableTableSelection(selection): void

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

Parameters​
selection​

TableSelection | null

Returns​

void

getTable()​

getTable(): TableDOMTable

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

Returns​

TableDOMTable

removeListeners()​

removeListeners(): void

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

Returns​

void

trackTable()​

trackTable(): void

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

Returns​

void


TableRowNode​

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

Extends​

Constructors​

Constructor​

new TableRowNode(height?, key?): TableRowNode

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

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

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

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

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

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

Returns​

false

Overrides​

ElementNode.canIndent

createDOM()​

createDOM(config): HTMLElement

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

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

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

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

Returns​

number | undefined

isShadowRoot()​

isShadowRoot(): boolean

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

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

setHeight()​

setHeight(height?): this

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

Parameters​
height?​

number

Returns​

this

updateDOM()​

updateDOM(prevNode): boolean

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

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

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

Properties​

maxColumn​

maxColumn: number

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

maxRow​

maxRow: number

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

minColumn​

minColumn: number

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

minRow​

minRow: number

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


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

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


SerializedTableNode​

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

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


SerializedTableRowNode​

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

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


TableCellHeaderState​

TableCellHeaderState = typeof TableCellHeaderStates[keyof typeof TableCellHeaderStates]

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


TableDOMCell​

TableDOMCell = object

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

Properties​

elem​

elem: HTMLElement

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

hasBackgroundColor​

hasBackgroundColor: boolean

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

highlighted​

highlighted: boolean

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

x​

x: number

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

y​

y: number

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


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

Returns​

void

Deprecated​

renamed to $deleteTableColumnAtSelection


$deleteTableRow__EXPERIMENTAL​

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

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

Returns​

void

Deprecated​

renamed to $deleteTableRowAtSelection


$insertTableColumn__EXPERIMENTAL​

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

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

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

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

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

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

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

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

Parameters​

headerState?​

number = TableCellHeaderStates.NO_STATUS

colSpan?​

number = 1

width?​

number

Returns​

TableCellNode


$createTableNode()​

$createTableNode(): TableNode

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

Returns​

TableNode


$createTableNodeWithDimensions()​

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

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

Parameters​

rowCount​

number

columnCount​

number

includeHeaders?​

InsertTableCommandPayloadHeaders = true

Returns​

TableNode


$createTableRowNode()​

$createTableRowNode(height?): TableRowNode

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

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

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

Returns​

void


$deleteTableRowAtSelection()​

$deleteTableRowAtSelection(): void

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

Returns​

void


$findCellNode()​

$findCellNode(node): TableCellNode | null

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

Parameters​

node​

LexicalNode

Returns​

TableCellNode | null


$findTableNode()​

$findTableNode(node): TableNode | null

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

Parameters​

node​

LexicalNode

Returns​

TableNode | null


$getElementForTableNode()​

$getElementForTableNode(editor, tableNode): TableDOMTable

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

Parameters​

editor​

LexicalEditor

tableNode​

TableNode

Returns​

TableDOMTable


$getNodeTriplet()​

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

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

Parameters​

source​

LexicalNode | PointType | TableCellNode

Returns​

[TableCellNode, TableRowNode, TableNode]


$getTableAndElementByKey()​

$getTableAndElementByKey(tableNodeKey, editor?): object

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

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

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

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

Parameters​

tableCellNode​

TableCellNode

Returns​

number


$getTableNodeFromLexicalNodeOrThrow()​

$getTableNodeFromLexicalNodeOrThrow(startingNode): TableNode

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

Parameters​

startingNode​

LexicalNode

Returns​

TableNode


$getTableRowIndexFromTableCellNode()​

$getTableRowIndexFromTableCellNode(tableCellNode): number

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

Parameters​

tableCellNode​

TableCellNode

Returns​

number


$getTableRowNodeFromTableCellNodeOrThrow()​

$getTableRowNodeFromTableCellNodeOrThrow(startingNode): TableRowNode

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

Parameters​

startingNode​

LexicalNode

Returns​

TableRowNode


$insertTableColumn()​

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

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

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

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

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

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

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

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

Parameters​

editor?​

LexicalEditor = ...

Returns​

boolean


$isSimpleTable()​

$isSimpleTable(table): boolean

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

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

Parameters​

editor?​

LexicalEditor = ...

Returns​

boolean


$isTableCellNode()​

$isTableCellNode(node): node is TableCellNode

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

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is TableCellNode


$isTableNode()​

$isTableNode(node): node is TableNode

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

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is TableNode


$isTableRowNode()​

$isTableRowNode(node): node is TableRowNode

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

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

Parameters​

cellNodes​

TableCellNode[]

Returns​

TableCellNode | null


$moveTableColumn()​

$moveTableColumn(tableNode, originColumn, targetColumn): void

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

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

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

Parameters​

tableNode​

TableNode

indexToDelete​

number

Returns​

TableNode


$setTableColumnIsHeader()​

$setTableColumnIsHeader(tableNode, columnIndex, isHeader): void

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

Parameters​

tableNode​

TableNode

columnIndex​

number

isHeader​

boolean

Returns​

void


$setTableRowIsHeader()​

$setTableRowIsHeader(tableNode, rowIndex, isHeader): void

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

Parameters​

tableNode​

TableNode

rowIndex​

number

isHeader​

boolean

Returns​

void


$unmergeCell()​

$unmergeCell(): void

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

Returns​

void


$unmergeCellNode()​

$unmergeCellNode(cellNode): void

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

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

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

Parameters​

node​

Node | null

Returns​

TableDOMCell | null


getTableElement()​

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

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

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

Parameters​

tableElement​

HTMLTableElementWithWithTableSelectionState

Returns​

TableObserver | null


registerTableCellUnmergeTransform()​

registerTableCellUnmergeTransform(editor): () => void

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

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

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

Parameters​

editor​

LexicalEditor

hasTabHandler?​

boolean = true

Returns​

() => void


setScrollableTablesActive()​

setScrollableTablesActive(editor, active): void

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

Parameters​

editor​

LexicalEditor

active​

boolean

Returns​

void