Skip to main content

@lexical/table

Classes​

TableCellNode​

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

Extends​

Constructors​

Constructor​

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

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

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

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

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

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

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

Returns​

false

Overrides​

ElementNode.canIndent

collapseAtStart()​

collapseAtStart(): true

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

Returns​

true

Overrides​

ElementNode.collapseAtStart

createDOM()​

createDOM(config): HTMLTableCellElement

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

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

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

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

Returns​

string | null

getColSpan()​

getColSpan(): number

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

Returns​

number

getHeaderStyles()​

getHeaderStyles(): number

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

Returns​

number

getRowSpan()​

getRowSpan(): number

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

Returns​

number

getTag()​

getTag(): "td" | "th"

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

Returns​

"td" | "th"

getVerticalAlign()​

getVerticalAlign(): string | undefined

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

Returns​

string | undefined

getWidth()​

getWidth(): number | undefined

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

Returns​

number | undefined

hasHeader()​

hasHeader(): boolean

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

Returns​

boolean

hasHeaderState()​

hasHeaderState(headerState): boolean

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

Parameters​
headerState​

number

Returns​

boolean

isShadowRoot()​

isShadowRoot(): boolean

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

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

setBackgroundColor()​

setBackgroundColor(newBackgroundColor): this

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

Parameters​
newBackgroundColor​

string | null

Returns​

this

setColSpan()​

setColSpan(colSpan): this

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

Parameters​
colSpan​

number

Returns​

this

setHeaderStyles()​

setHeaderStyles(headerState, mask?): this

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

Parameters​
headerState​

number

mask?​

number = TableCellHeaderStates.BOTH

Returns​

this

setRowSpan()​

setRowSpan(rowSpan): this

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

Parameters​
rowSpan​

number

Returns​

this

setVerticalAlign()​

setVerticalAlign(newVerticalAlign): this

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

Parameters​
newVerticalAlign​

string | null | undefined

Returns​

this

setWidth()​

setWidth(width): this

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

Parameters​
width​

number | undefined

Returns​

this

toggleHeaderStyle()​

toggleHeaderStyle(headerStateToToggle): this

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

Parameters​
headerStateToToggle​

number

Returns​

this

updateDOM()​

updateDOM(prevNode): boolean

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

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

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

Extends​

Properties​

__colWidths​

__colWidths: readonly number[] | undefined = undefined

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

__frozenColumnCount​

__frozenColumnCount: number = 0

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

__frozenRowCount​

__frozenRowCount: number = 0

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

Methods​

$config()​

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

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

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

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

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

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

Returns​

false

Overrides​

ElementNode.canIndent

canSelectBefore()​

canSelectBefore(): true

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

Returns​

true

createDOM()​

createDOM(config, editor?): HTMLElement

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

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

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

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

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

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableCellNode | null

getCellNodeFromCordsOrThrow()​

getCellNodeFromCordsOrThrow(x, y, table): TableCellNode

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

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableCellNode

getColumnCount()​

getColumnCount(): number

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

Returns​

number

getColWidths()​

getColWidths(): readonly number[] | undefined

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

Returns​

readonly number[] | undefined

getCordsFromCellNode()​

getCordsFromCellNode(tableCellNode, table): object

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

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

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableDOMCell | null

getDOMCellFromCordsOrThrow()​

getDOMCellFromCordsOrThrow(x, y, table): TableDOMCell

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

Parameters​
x​

number

y​

number

table​

TableDOMTable

Returns​

TableDOMCell

getDOMSlot()​

getDOMSlot(element): ElementDOMSlot<HTMLTableElement>

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

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

Returns​

number

getFrozenRows()​

getFrozenRows(): number

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

Returns​

number

getRowStriping()​

getRowStriping(): boolean

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

Returns​

boolean

isShadowRoot()​

isShadowRoot(): boolean

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

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

scaleDOMColWidths()​

scaleDOMColWidths(dom, scale): void

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

Parameters​
dom​

HTMLElement

scale​

number

Returns​

void

setColWidths()​

setColWidths(colWidths): this

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

Parameters​
colWidths​

readonly number[] | undefined

Returns​

this

setFrozenColumns()​

setFrozenColumns(columnCount): this

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

Parameters​
columnCount​

number

Returns​

this

setFrozenRows()​

setFrozenRows(rowCount): this

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

Parameters​
rowCount​

number

Returns​

this

setRowStriping()​

setRowStriping(newRowStriping): this

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

Parameters​
newRowStriping​

boolean

Returns​

this

updateDOM()​

updateDOM(prevNode, dom, config): boolean

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

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

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

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

Parameters​
prevNode​

TableNode | null

tableWrapper​

HTMLDivElement

tableElement​

HTMLTableElement

config​

EditorConfig

Returns​

void


TableObserver​

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

Constructors​

Constructor​

new TableObserver(editor, tableNodeKey): TableObserver

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

Parameters​
editor​

LexicalEditor

tableNodeKey​

string

Returns​

TableObserver

Properties​

abortController​

abortController: AbortController

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

anchorCell​

anchorCell: TableDOMCell | null

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

anchorCellNodeKey​

anchorCellNodeKey: string | null

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

anchorX​

anchorX: number

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

anchorY​

anchorY: number

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

editor​

editor: LexicalEditor

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

focusCell​

focusCell: TableDOMCell | null

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

focusCellNodeKey​

focusCellNodeKey: string | null

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

focusX​

focusX: number

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

focusY​

focusY: number

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

hasHijackedSelectionStyles​

hasHijackedSelectionStyles: boolean

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

isHighlightingCells​

isHighlightingCells: boolean

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

isSelecting​

isSelecting: boolean

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

listenerOptions​

listenerOptions: object

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

signal​

signal: AbortSignal

listenersToRemove​

listenersToRemove: Set<() => void>

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

pointerType​

pointerType: string | null

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

table​

table: TableDOMTable

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

tableNodeKey​

tableNodeKey: string

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

tableSelection​

tableSelection: TableSelection | null

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

Methods​

$clearHighlight()​

$clearHighlight(setEmptySelection?): void

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

Parameters​
setEmptySelection?​

boolean = true

Returns​

void

$clearText()​

$clearText(): void

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

Returns​

void

$disableHighlightStyle()​

$disableHighlightStyle(): void

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

Returns​

void

$enableHighlightStyle()​

$enableHighlightStyle(): void

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

Returns​

void

$formatCells()​

$formatCells(type): void

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

Parameters​
type​

TextFormatType

Returns​

void

$getAnchorTableCell()​

$getAnchorTableCell(): TableCellNode | null

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

Returns​

TableCellNode | null

$getAnchorTableCellOrThrow()​

$getAnchorTableCellOrThrow(): TableCellNode

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

Returns​

TableCellNode

$getFocusTableCell()​

$getFocusTableCell(): TableCellNode | null

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

Returns​

TableCellNode | null

$getFocusTableCellOrThrow()​

$getFocusTableCellOrThrow(): TableCellNode

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

Returns​

TableCellNode

$lookup()​

$lookup(): object

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

Returns​

object

tableElement​

tableElement: HTMLTableElementWithWithTableSelectionState

tableNode​

tableNode: TableNode

$setAnchorCellForSelection()​

$setAnchorCellForSelection(cell): void

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

Parameters​
cell​

TableDOMCell

Returns​

void

$setFocusCellForSelection()​

$setFocusCellForSelection(cell, ignoreStart?): boolean

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

Parameters​
cell​

TableDOMCell

ignoreStart?​

boolean = false

Returns​

boolean

$updateTableTableSelection()​

$updateTableTableSelection(selection): void

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

Parameters​
selection​

TableSelection | null

Returns​

void

getTable()​

getTable(): TableDOMTable

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

Returns​

TableDOMTable

removeListeners()​

removeListeners(): void

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

Returns​

void

trackTable()​

trackTable(): void

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

Returns​

void


TableRowNode​

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

Extends​

Constructors​

Constructor​

new TableRowNode(height?, key?): TableRowNode

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

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

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

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

Returns​

false

Overrides​

ElementNode.canBeEmpty

canIndent()​

canIndent(): false

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

Returns​

false

Overrides​

ElementNode.canIndent

createDOM()​

createDOM(config): HTMLElement

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

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

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

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

Returns​

number | undefined

isShadowRoot()​

isShadowRoot(): boolean

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

Returns​

boolean

Overrides​

ElementNode.isShadowRoot

setHeight()​

setHeight(height?): this

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

Parameters​
height?​

number

Returns​

this

updateDOM()​

updateDOM(prevNode): boolean

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

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

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

Properties​

hasCellBackgroundColor​

hasCellBackgroundColor: boolean

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

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

hasCellMerge​

hasCellMerge: boolean

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

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

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

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

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


TableSelection​

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

Implements​

Properties​

_cachedNodes​

_cachedNodes: LexicalNode[] | null

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

Implementation of​

BaseSelection._cachedNodes

anchor​

anchor: PointType

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

dirty​

dirty: boolean

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

Implementation of​

BaseSelection.dirty

focus​

focus: PointType

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

tableKey​

tableKey: string

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

Methods​

clone()​

clone(): TableSelection

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

Returns​

TableSelection

Implementation of​

BaseSelection.clone

extract()​

extract(): LexicalNode[]

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

Returns​

LexicalNode[]

Implementation of​

BaseSelection.extract

getCachedNodes()​

getCachedNodes(): LexicalNode[] | null

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

Returns​

LexicalNode[] | null

Implementation of​

BaseSelection.getCachedNodes

getNodes()​

getNodes(): LexicalNode[]

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

Returns​

LexicalNode[]

Implementation of​

BaseSelection.getNodes

getShape()​

getShape(): TableSelectionShape

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

Returns​

TableSelectionShape

getStartEndPoints()​

getStartEndPoints(): [PointType, PointType]

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

Returns​

[PointType, PointType]

Implementation of​

BaseSelection.getStartEndPoints

getTextContent()​

getTextContent(): string

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

Returns​

string

Implementation of​

BaseSelection.getTextContent

hasFormat()​

hasFormat(type): boolean

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

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

Parameters​
nodes​

LexicalNode[]

Returns​

void

Implementation of​

BaseSelection.insertNodes

insertRawText()​

insertRawText(text): void

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

Parameters​
text​

string

Returns​

void

Implementation of​

BaseSelection.insertRawText

insertText()​

insertText(): void

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

Returns​

void

Implementation of​

BaseSelection.insertText

is()​

is(selection): boolean

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

Parameters​
selection​

BaseSelection | null

Returns​

boolean

Implementation of​

BaseSelection.is

isBackward()​

isBackward(): boolean

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

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

Returns​

boolean

Implementation of​

BaseSelection.isCollapsed

isValid()​

isValid(): boolean

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

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

Parameters​
tableKey​

string

anchorCellKey​

string

focusCellKey​

string

Returns​

void

setCachedNodes()​

setCachedNodes(nodes): void

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

Parameters​
nodes​

LexicalNode[] | null

Returns​

void

Implementation of​

BaseSelection.setCachedNodes

Type Aliases​

HTMLTableElementWithWithTableSelectionState​

HTMLTableElementWithWithTableSelectionState = HTMLTableElement & object

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

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


SerializedTableNode​

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

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


SerializedTableRowNode​

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

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


TableDOMCell​

TableDOMCell = object

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

Properties​

elem​

elem: HTMLElement

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

hasBackgroundColor​

hasBackgroundColor: boolean

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

highlighted​

highlighted: boolean

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

x​

x: number

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

y​

y: number

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


TableMapType​

TableMapType = TableMapValueType[][]

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


TableMapValueType​

TableMapValueType = object

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

Properties​

cell​

cell: TableCellNode

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

startColumn​

startColumn: number

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

startRow​

startRow: number

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


TableSelectionShape​

TableSelectionShape = object

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

Properties​

fromX​

fromX: number

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

fromY​

fromY: number

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

toX​

toX: number

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

toY​

toY: number

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

Variables​

$deleteTableColumn__EXPERIMENTAL​

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

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

Returns​

void

Deprecated​

renamed to $deleteTableColumnAtSelection


$deleteTableRow__EXPERIMENTAL​

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

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

Returns​

void

Deprecated​

renamed to $deleteTableRowAtSelection


$insertTableColumn__EXPERIMENTAL​

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

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

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

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

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

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

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​

$computeTableMap()​

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

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

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

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

Parameters​

headerState?​

number = TableCellHeaderStates.NO_STATUS

colSpan?​

number = 1

width?​

number

Returns​

TableCellNode


$createTableNode()​

$createTableNode(): TableNode

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

Returns​

TableNode


$createTableNodeWithDimensions()​

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

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

Parameters​

rowCount​

number

columnCount​

number

includeHeaders?​

InsertTableCommandPayloadHeaders = true

Returns​

TableNode


$createTableRowNode()​

$createTableRowNode(height?): TableRowNode

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

Parameters​

height?​

number

Returns​

TableRowNode


$createTableSelection()​

$createTableSelection(): TableSelection

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

Returns​

TableSelection


$createTableSelectionFrom()​

$createTableSelectionFrom(tableNode, anchorCell, focusCell): TableSelection

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

Parameters​

tableNode​

TableNode

anchorCell​

TableCellNode

focusCell​

TableCellNode

Returns​

TableSelection


$deleteTableColumn()​

$deleteTableColumn(tableNode, targetIndex): TableNode

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

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

Returns​

void


$deleteTableRowAtSelection()​

$deleteTableRowAtSelection(): void

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

Returns​

void


$findCellNode()​

$findCellNode(node): TableCellNode | null

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

Parameters​

node​

LexicalNode

Returns​

TableCellNode | null


$findTableNode()​

$findTableNode(node): TableNode | null

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

Parameters​

node​

LexicalNode

Returns​

TableNode | null


$getElementForTableNode()​

$getElementForTableNode(editor, tableNode): TableDOMTable

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

Parameters​

editor​

LexicalEditor

tableNode​

TableNode

Returns​

TableDOMTable


$getNodeTriplet()​

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

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

Parameters​

source​

LexicalNode | PointType | TableCellNode

Returns​

[TableCellNode, TableRowNode, TableNode]


$getTableAndElementByKey()​

$getTableAndElementByKey(tableNodeKey, editor?): object

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

Parameters​

tableNodeKey​

string

editor?​

LexicalEditor = ...

Returns​

object

tableElement​

tableElement: HTMLTableElementWithWithTableSelectionState

tableNode​

tableNode: TableNode


$getTableCellNodeFromLexicalNode()​

$getTableCellNodeFromLexicalNode(startingNode): TableCellNode | null

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

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

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

Parameters​

tableCellNode​

TableCellNode

Returns​

number


$getTableNodeFromLexicalNodeOrThrow()​

$getTableNodeFromLexicalNodeOrThrow(startingNode): TableNode

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

Parameters​

startingNode​

LexicalNode

Returns​

TableNode


$getTableRowIndexFromTableCellNode()​

$getTableRowIndexFromTableCellNode(tableCellNode): number

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

Parameters​

tableCellNode​

TableCellNode

Returns​

number


$getTableRowNodeFromTableCellNodeOrThrow()​

$getTableRowNodeFromTableCellNodeOrThrow(startingNode): TableRowNode

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

Parameters​

startingNode​

LexicalNode

Returns​

TableRowNode


$insertTableColumn()​

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

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

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

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

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

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

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

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

Parameters​

editor?​

LexicalEditor = ...

Returns​

boolean


$isSimpleTable()​

$isSimpleTable(table): boolean

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

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

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is TableCellNode


$isTableNode()​

$isTableNode(node): node is TableNode

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

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is TableNode


$isTableRowNode()​

$isTableRowNode(node): node is TableRowNode

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

Parameters​

node​

LexicalNode | null | undefined

Returns​

node is TableRowNode


$isTableSelection()​

$isTableSelection(x): x is TableSelection

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

Parameters​

x​

unknown

Returns​

x is TableSelection


$mergeCells()​

$mergeCells(cellNodes): TableCellNode | null

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

Parameters​

cellNodes​

TableCellNode[]

Returns​

TableCellNode | null


$moveTableColumn()​

$moveTableColumn(tableNode, originColumn, targetColumn): void

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

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

Parameters​

tableNode​

TableNode

indexToDelete​

number

Returns​

TableNode


$unmergeCell()​

$unmergeCell(): void

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

Returns​

void


applyTableHandlers()​

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

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

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

Parameters​

node​

Node | null

Returns​

TableDOMCell | null


getTableElement()​

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

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

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

Parameters​

tableElement​

HTMLTableElementWithWithTableSelectionState

Returns​

TableObserver | null


registerTableCellUnmergeTransform()​

registerTableCellUnmergeTransform(editor): () => void

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

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

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

Parameters​

editor​

LexicalEditor

hasTabHandler?​

boolean = true

Returns​

() => void


setScrollableTablesActive()​

setScrollableTablesActive(editor, active): void

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

Parameters​

editor​

LexicalEditor

active​

boolean

Returns​

void