@lexical/table
Classes
TableCellNode
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:119
Extends
Constructors
Constructor
new TableCellNode(
headerState?,colSpan?,width?,key?):TableCellNode
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:161
Parameters
headerState?
number = TableCellHeaderStates.NO_STATUS
colSpan?
number = 1
width?
number
key?
string
Returns
Inherited from
Properties
importDOM?
staticoptionalimportDOM?: () =>DOMConversionMap<any> |null
Defined in: packages/lexical/src/LexicalNode.ts:1161
Returns
DOMConversionMap<any> | null
Inherited from
Methods
$config()
$config():
BaseStaticNodeConfig&StaticNodeConfigAccessor<{$transform: { };extends: typeofLexicalNode;generated:GeneratedJSONFactory;json:NodeSerializationSchema<ElementNode, {direction?:"ltr"|"rtl"|null;format?:""|"left"|"start"|"center"|"right"|"end"|"justify";indent?:string|number;textFormat?:string|number;textStyle?:string; }>; }> &object&StaticNodeTypeAccessor<"tablecell"> &StaticNodeConfigAccessor<{extends: typeofElementNode;generated:GeneratedJSONFactory;importDOM: {td: () =>object;th: () =>object; };json:NodeSerializationSchema<TableCellNode, {backgroundColor?:string|null;colSpan?:string|number;headerState?:string|number;rowSpan?:string|number;verticalAlign?:"bottom"|"middle";width?:string|number; }>; }>
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:143
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 & StaticNodeConfigAccessor<{ $transform: { }; extends: typeof LexicalNode; generated: GeneratedJSONFactory; json: NodeSerializationSchema<ElementNode, { direction?: "ltr" | "rtl" | null; format?: "" | "left" | "start" | "center" | "right" | "end" | "justify"; indent?: string | number; textFormat?: string | number; textStyle?: string; }>; }> & object & StaticNodeTypeAccessor<"tablecell"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; generated: GeneratedJSONFactory; importDOM: { td: () => object; th: () => object; }; json: NodeSerializationSchema<TableCellNode, { backgroundColor?: string | null; colSpan?: string | number; headerState?: string | number; rowSpan?: string | number; verticalAlign?: "bottom" | "middle"; width?: string | number; }>; }>
Example
class MyNode extends TextNode {
$config() {
return this.config('my-node', {extends: TextNode});
}
}
Inherited from
afterCloneFrom()
afterCloneFrom(
prevNode):void
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:329
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;
}
}
Inherited from
append()
append(...
nodesToAppend):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:774
Parameters
nodesToAppend
...LexicalNode[]
Returns
this
Inherited from
canBeEmpty()
canBeEmpty():
false
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:349
Returns
false
Inherited from
canIndent()
canIndent():
false
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:353
Returns
false
Inherited from
canInsertTextAfter()
canInsertTextAfter():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1078
Returns
boolean
Inherited from
ElementNode.canInsertTextAfter
canInsertTextBefore()
canInsertTextBefore():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1075
Returns
boolean
Inherited from
ElementNode.canInsertTextBefore
canMergeWhenEmpty()
canMergeWhenEmpty():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1121
Determines whether this node, when empty, can merge with a first block of nodes being inserted.
This method is specifically called in RangeSelection.insertNodes to determine merging behavior during nodes insertion.
Returns
boolean
Example
// In a ListItemNode or QuoteNode implementation:
canMergeWhenEmpty(): true {
return true;
}
Inherited from
clear()
clear():
this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:768
Returns
this
Inherited from
collapseAtStart()
collapseAtStart():
true
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:345
Returns
true
Inherited from
config()
Call Signature
config<
Config>(type,config):AbstractStaticNodeConfigRecord<Config>
Defined in: packages/lexical/src/LexicalNode.ts:1065
This is a convenience method for $config that aids in type inference. See LexicalNode.$config for example usage.
An abstract base class that has no concrete node type may pass a
well-known symbol (by convention Symbol.for(<NodeClassName>)) instead of
a string type to declare configuration shared with its subclasses.
Type Parameters
Config
Config extends StaticNodeConfigValue<TableCellNode, string>
Parameters
type
symbol
config
Config
Returns
AbstractStaticNodeConfigRecord<Config>
Inherited from
Call Signature
config<
Type,Config>(type,config):StaticNodeConfigRecord<Type,Config>
Defined in: packages/lexical/src/LexicalNode.ts:1069
This is a convenience method for $config that aids in type inference. See LexicalNode.$config for example usage.
An abstract base class that has no concrete node type may pass a
well-known symbol (by convention Symbol.for(<NodeClassName>)) instead of
a string type to declare configuration shared with its subclasses.
Type Parameters
Type
Type extends string
Config
Config extends StaticNodeConfigValue<TableCellNode, Type>
Parameters
type
Type
config
Config
Returns
StaticNodeConfigRecord<Type, Config>
Inherited from
createDOM()
createDOM(
config):HTMLTableCellElement
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:176
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
Returns
HTMLTableCellElement
Inherited from
createParentElementNode()
createParentElementNode():
ElementNode
Defined in: packages/lexical/src/LexicalNode.ts:2312
The creation logic for any required parent. Should be implemented if isParentRequired returns true.
Returns
Inherited from
ElementNode.createParentElementNode
excludeFromCopy()
excludeFromCopy(
destination?):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1061
Parameters
destination?
"clone" | "html"
Returns
boolean
Inherited from
exportDOM()
exportDOM(
editor):DOMExportOutput
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:204
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
Returns
Inherited from
exportJSON()
Call Signature
exportJSON(
compact?):SerializedTableCellNode
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:120
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.
The base implementation writes every property the node's schema declares
(its own and those it inherits), reading each through its getter —
get<Prop> by default, or the name recorded with withAccessors. A getter
that returns undefined omits its property. Override this only for output
a schema can not describe, and call super.exportJSON(compact) when you do.
This may serialize the instance as-is, without resolving the latest version. A property declared with withField is read straight off the node, which is the optimization the serialization walk is built on — every node the walk reaches comes from the EditorState's node map and is already current, so it resolves nothing per node.
So on a reference that a getWritable() (any set<Prop>) has since
superseded, this writes pre-mutation values. Which properties do is not
something to rely on: a property whose accessor a subclass overrode still
goes through that accessor and resolves the latest, so one node can write
a current text beside a stale style. Call
node.getLatest().exportJSON() whenever you hold such a reference rather
than reasoning about which properties resolve.
This is a breaking change. Every property previously went through an
accessor, and every accessor resolves getLatest(), so a stale reference
exported current values.
Parameters
compact?
false
Write the compact form: omit a property the parser derives
rather than reads, one whose value is the schema default parsing would
restore, and the deprecated version. The two forms describe the same
document. A node that overrides this and ignores the flag simply keeps
writing the full form, which still parses.
Returns
Inherited from
Call Signature
exportJSON(
compact):SerializedPartial<SerializedTableCellNode>
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:121
The compact form omits properties, so what it returns is the partial
serialized type — every node-specific property optional — rather than the
full one. Passing a boolean whose value is not statically known selects
this overload too, which is right: neither form can be promised then.
Parameters
compact
boolean
Returns
SerializedPartial<SerializedTableCellNode>
See
Inherited from
extractWithChild()
extractWithChild(
child,selection,destination):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1100
Parameters
child
selection
BaseSelection | null
destination
"clone" | "html"
Returns
boolean
Inherited from
getAllTextNodes()
getAllTextNodes():
TextNode[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:420
Returns
TextNode[]
Inherited from
getBackgroundColor()
getBackgroundColor():
string|null
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:285
Returns
string | null
getChildAtIndex()
Call Signature
getChildAtIndex(
index):LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:605
Returns the child of this node at the given index, or null if the index is out of range.
Parameters
index
number
Returns
LexicalNode | null
Inherited from
Call Signature
getChildAtIndex<
T>(index):T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:612
Type Parameters
T
T extends LexicalNode
Parameters
index
number
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getChildAtIndex(index) as T | null, and will
be removed in a future release. Call this method without a type
argument and narrow the result with a type guard instead.
Inherited from
getChildren()
Call Signature
getChildren():
LexicalNode[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:374
Returns the children of this node, in document order.
Returns
Inherited from
Call Signature
getChildren<
T>():T[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:381
Type Parameters
T
T extends LexicalNode
Returns
T[]
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getChildren() as T[], and will be
removed in a future release. Call this method without a type argument
and narrow the results with a type guard instead.
Inherited from
getChildrenKeys()
getChildrenKeys():
string[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:391
Returns
string[]
Inherited from
getChildrenSize()
getChildrenSize():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:400
Returns
number
Inherited from
getColSpan()
getColSpan():
number
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:232
Returns
number
getCommonAncestor()
getCommonAncestor<
T>(node):T|null
Defined in: packages/lexical/src/LexicalNode.ts:1506
Type Parameters
T
T extends ElementNode = ElementNode
Parameters
node
the other node to find the common ancestor of.
Returns
T | null
Deprecated
Returns the closest common ancestor of this node and the provided one or null if one cannot be found.
Inherited from
getDescendantByIndex()
Call Signature
getDescendantByIndex(
index):LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:505
Returns the deepest descendant corresponding to the child at the given index, or null if this node has no children.
Parameters
index
number
Returns
LexicalNode | null
Inherited from
ElementNode.getDescendantByIndex
Call Signature
getDescendantByIndex<
T>(index):T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:512
Type Parameters
T
T extends LexicalNode
Parameters
index
number
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getDescendantByIndex(index) as T | null, and
will be removed in a future release. Call this method without a type
argument and narrow the result with a type guard instead.
Inherited from
ElementNode.getDescendantByIndex
getDirection()
getDirection():
"ltr"|"rtl"|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:678
Returns
"ltr" | "rtl" | null
Inherited from
getDOMSlot()
getDOMSlot(
element):ElementDOMSlot<HTMLElement>
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:964
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<HTMLElement>
Inherited from
getFirstChild()
Call Signature
getFirstChild():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:536
Returns the first child of this node, or null if it has no children.
Returns
LexicalNode | null
Inherited from
Call Signature
getFirstChild<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:543
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getFirstChild() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getFirstChildOrThrow()
Call Signature
getFirstChildOrThrow():
LexicalNode
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:552
Returns the first child of this node, or throws if it has no children.
Returns
Inherited from
ElementNode.getFirstChildOrThrow
Call Signature
getFirstChildOrThrow<
T>():T
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:559
Type Parameters
T
T extends LexicalNode
Returns
T
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getFirstChildOrThrow() as T, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getFirstChildOrThrow
getFirstDescendant()
Call Signature
getFirstDescendant():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:459
Returns the deepest first descendant of this node, or null if it has no children.
Descendant navigation is children-only by design: it feeds selectStart / selectEnd and selection, which must not see slots (slots are isolated).
Returns
LexicalNode | null
Inherited from
ElementNode.getFirstDescendant
Call Signature
getFirstDescendant<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:466
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getFirstDescendant() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getFirstDescendant
getFormat()
getFormat():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:355
Returns
number
Inherited from
getFormatFlags()
getFormatFlags(
type,alignWithFormat):number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:702
Returns the format flags applied to the node as a 32-bit integer.
Parameters
type
alignWithFormat
number | null
Returns
number
a number representing the TextFormatTypes applied to the node.
Inherited from
getFormatType()
getFormatType():
ElementFormatType
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:359
Returns
Inherited from
getHeaderStyles()
getHeaderStyles():
number
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:265
Returns
number
getIndent()
getIndent():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:367
Returns
number
Inherited from
getIndexWithinParent()
getIndexWithinParent():
number
Defined in: packages/lexical/src/LexicalNode.ts:1283
Returns the zero-based index of this node within the parent.
Returns
number
Inherited from
ElementNode.getIndexWithinParent
getKey()
getKey():
string
Defined in: packages/lexical/src/LexicalNode.ts:1275
Returns this nodes key.
Returns
string
Inherited from
getLastChild()
Call Signature
getLastChild():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:570
Returns the last child of this node, or null if it has no children.
Returns
LexicalNode | null
Inherited from
Call Signature
getLastChild<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:577
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getLastChild() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getLastChildOrThrow()
Call Signature
getLastChildOrThrow():
LexicalNode
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:586
Returns the last child of this node, or throws if it has no children.
Returns
Inherited from
ElementNode.getLastChildOrThrow
Call Signature
getLastChildOrThrow<
T>():T
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:593
Type Parameters
T
T extends LexicalNode
Returns
T
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getLastChildOrThrow() as T, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getLastChildOrThrow
getLastDescendant()
Call Signature
getLastDescendant():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:482
Returns the deepest last descendant of this node, or null if it has no children.
Returns
LexicalNode | null
Inherited from
Call Signature
getLastDescendant<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:489
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getLastDescendant() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getLatest()
getLatest():
this
Defined in: packages/lexical/src/LexicalNode.ts:1656
Returns the latest version of the node from the active EditorState. This is used to avoid getting values from stale node references.
Returns
this
Inherited from
getNextSibling()
Call Signature
getNextSibling():
LexicalNode|null
Defined in: packages/lexical/src/LexicalNode.ts:1462
Returns the node after this one in the same parent, or null if there is no such node.
Returns
LexicalNode | null
Inherited from
Call Signature
getNextSibling<
T>():T|null
Defined in: packages/lexical/src/LexicalNode.ts:1469
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getNextSibling() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getNextSiblings()
Call Signature
getNextSiblings():
LexicalNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1480
Returns all nodes after this one in the same parent, in document order.
Returns
Inherited from
Call Signature
getNextSiblings<
T>():T[]
Defined in: packages/lexical/src/LexicalNode.ts:1487
Type Parameters
T
T extends LexicalNode
Returns
T[]
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getNextSiblings() as T[], and will be
removed in a future release. Call this method without a type argument
and narrow the results with a type guard instead.
Inherited from
getNodesBetween()
getNodesBetween(
targetNode):LexicalNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1575
Returns a list of nodes that are between this node and the target node in the EditorState.
Parameters
targetNode
the node that marks the other end of the range of nodes to be returned.
Returns
Inherited from
getParent()
Call Signature
getParent():
ElementNode|null
Defined in: packages/lexical/src/LexicalNode.ts:1303
Returns the parent of this node, or null if none is found.
Returns
ElementNode | null
Inherited from
Call Signature
getParent<
T>():T|null
Defined in: packages/lexical/src/LexicalNode.ts:1310
Type Parameters
T
T extends ElementNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getParent() as T | null, and will be removed
in a future release. Call this method without a type argument and
narrow the result with a type guard instead.
Inherited from
getParentKeys()
getParentKeys():
string[]
Defined in: packages/lexical/src/LexicalNode.ts:1401
Returns a list of the keys of every ancestor of this node, all the way up to the RootNode.
Returns
string[]
Inherited from
getParentOrThrow()
Call Signature
getParentOrThrow():
ElementNode
Defined in: packages/lexical/src/LexicalNode.ts:1323
Returns the parent of this node, or throws if none is found.
Returns
Inherited from
Call Signature
getParentOrThrow<
T>():T
Defined in: packages/lexical/src/LexicalNode.ts:1330
Type Parameters
T
T extends ElementNode
Returns
T
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getParentOrThrow() as T, and will be removed
in a future release. Call this method without a type argument and
narrow the result with a type guard instead.
Inherited from
getParents()
getParents():
ElementNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1386
Returns a list of the every ancestor of this node, all the way up to the RootNode.
Returns
Inherited from
getPreviousSibling()
Call Signature
getPreviousSibling():
LexicalNode|null
Defined in: packages/lexical/src/LexicalNode.ts:1415
Returns the node before this one in the same parent, or null if there is no such node.
Returns
LexicalNode | null
Inherited from
ElementNode.getPreviousSibling
Call Signature
getPreviousSibling<
T>():T|null
Defined in: packages/lexical/src/LexicalNode.ts:1422
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getPreviousSibling() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getPreviousSibling
getPreviousSiblings()
Call Signature
getPreviousSiblings():
LexicalNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1433
Returns all nodes before this one in the same parent, in document order.
Returns
Inherited from
ElementNode.getPreviousSiblings
Call Signature
getPreviousSiblings<
T>():T[]
Defined in: packages/lexical/src/LexicalNode.ts:1440
Type Parameters
T
T extends LexicalNode
Returns
T[]
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getPreviousSiblings() as T[], and will be
removed in a future release. Call this method without a type argument
and narrow the results with a type guard instead.
Inherited from
ElementNode.getPreviousSiblings
getRowSpan()
getRowSpan():
number
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:242
Returns
number
getStyle()
getStyle():
string
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:363
Returns
string
Inherited from
getTag()
getTag():
"td"|"th"
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:252
Returns
"td" | "th"
getTextContent()
getTextContent():
string
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:640
Returns the text content of the node. Override this for custom nodes that should have a representation in plain text format (for copy + paste, for example)
Returns
string
Inherited from
getTextContentSize()
getTextContentSize():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:659
Returns the length of the string produced by calling getTextContent on this node.
Returns
number
Inherited from
ElementNode.getTextContentSize
getTextFormat()
getTextFormat():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:682
Returns
number
Inherited from
getTextStyle()
getTextStyle():
string
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:708
Returns
string
Inherited from
getTopLevelElement()
getTopLevelElement():
ElementNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:241
Returns the highest (in the EditorState tree) non-root ancestor of this node, or null if none is found. See $isRootOrShadowRoot for more information on which Elements comprise "roots".
Returns
ElementNode | null
Inherited from
ElementNode.getTopLevelElement
getTopLevelElementOrThrow()
getTopLevelElementOrThrow():
ElementNode
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:242
Returns the highest (in the EditorState tree) non-root ancestor of this node, or throws if none is found. See $isRootOrShadowRoot for more information on which Elements comprise "roots".
Returns
Inherited from
ElementNode.getTopLevelElementOrThrow
getType()
getType():
string
Defined in: packages/lexical/src/LexicalNode.ts:1186
Returns the string type of this node.
Returns
string
Inherited from
getVerticalAlign()
getVerticalAlign():
string|undefined
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:295
Returns
string | undefined
getWidth()
getWidth():
number|undefined
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:275
Returns
number | undefined
getWritable()
getWritable():
this
Defined in: packages/lexical/src/LexicalNode.ts:1677
Returns a mutable version of the node using $cloneWithProperties if necessary. Will throw an error if called outside of a Lexical Editor LexicalEditor.update callback.
Returns
this
Inherited from
hasFormat()
hasFormat(
type):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:686
Parameters
type
Returns
boolean
Inherited from
hasHeader()
hasHeader():
boolean
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:326
Returns
boolean
hasHeaderState()
hasHeaderState(
headerState):boolean
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:322
Parameters
headerState
number
Returns
boolean
hasTextFormat()
hasTextFormat(
type):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:693
Parameters
type
Returns
boolean
Inherited from
insertAfter()
insertAfter(
nodeToInsert,restoreSelection?):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:2116
Inserts a node after this LexicalNode (as the next sibling).
Parameters
nodeToInsert
The node to insert after this one.
restoreSelection?
boolean = true
Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete.
Returns
Inherited from
insertBefore()
insertBefore(
nodeToInsert,restoreSelection?):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:2223
Inserts a node before this LexicalNode (as the previous sibling).
Parameters
nodeToInsert
The node to insert before this one.
restoreSelection?
boolean = true
Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete.
Returns
Inherited from
insertNewAfter()
insertNewAfter(
selection,restoreSelection?):LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1038
Parameters
selection
restoreSelection?
boolean
Returns
LexicalNode | null
Inherited from
is()
is(
object):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1523
Returns true if the provided node is the exact same one as this node, from Lexical's perspective. Always use this instead of referential equality.
Parameters
object
LexicalNode | null | undefined
the node to perform the equality comparison on.
Returns
boolean
Inherited from
isAttached()
isAttached():
boolean
Defined in: packages/lexical/src/LexicalNode.ts:1203
Returns true if there is a path between this node and the RootNode, false otherwise. This is a way of determining if the node is "attached" EditorState. Unattached nodes won't be reconciled and will ultimately be cleaned up by the Lexical GC.
Returns
boolean
Inherited from
isBefore()
isBefore(
targetNode):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1541
Returns true if this node logically precedes the target node in the editor state, false otherwise (including if there is no common ancestor).
Note that this notion of isBefore is based on post-order; a descendant node is always before its ancestors. See also $getCommonAncestor and $comparePointCaretNext for more flexible ways to determine the relative positions of nodes.
Parameters
targetNode
the node we're testing to see if it's after this one.
Returns
boolean
Inherited from
isDirty()
isDirty():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:410
Returns true if this node has been marked dirty during this update cycle.
Returns
boolean
Inherited from
isEmpty()
isEmpty():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:404
Returns
boolean
Inherited from
isInline()
isInline():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1086
If the method is overridden and returns true, ensure that canBeEmpty()
returns false for the inline node to work correctly
Returns
boolean
Inherited from
isLastChild()
isLastChild():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:415
Returns
boolean
Inherited from
isParentOf()
isParentOf(
targetNode):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1564
Returns true if this node is an ancestor of and distinct from the target node, false otherwise.
Parameters
targetNode
the would-be child node.
Returns
boolean
Inherited from
isParentRequired()
isParentRequired():
boolean
Defined in: packages/lexical/src/LexicalNode.ts:2304
Whether or not this node has a required parent. Used during copy + paste operations to normalize nodes that would otherwise be orphaned. For example, ListItemNodes without a ListNode parent or TextNodes with a ParagraphNode parent.
Returns
boolean
Inherited from
isSelected()
isSelected(
selection?):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1230
Returns true if this node is contained within the provided Selection., false otherwise. Relies on the algorithms implemented in BaseSelection.getNodes to determine what's included.
Parameters
selection?
BaseSelection | null
The selection that we want to determine if the node is in.
Returns
boolean
Inherited from
isShadowRoot()
isShadowRoot():
boolean
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:341
Returns
boolean
Inherited from
markDirty()
markDirty():
void
Defined in: packages/lexical/src/LexicalNode.ts:2387
Marks a node dirty, triggering transforms and forcing it to be reconciled during the update cycle.
Returns
void
Inherited from
remove()
remove(
preserveEmptyParent?):void
Defined in: packages/lexical/src/LexicalNode.ts:1948
Removes this LexicalNode from the EditorState. If the node isn't re-inserted somewhere, the Lexical garbage collector will eventually clean it up.
Parameters
preserveEmptyParent?
boolean
If falsy, the node's parent will be removed if it's empty after the removal operation. This is the default behavior, subject to other node heuristics such as ElementNode#canBeEmpty
Returns
void
Inherited from
replace()
replace<
N>(replaceWith,includeChildren?):N
Defined in: packages/lexical/src/LexicalNode.ts:1965
Replaces this LexicalNode with the provided node, optionally transferring the children of the replaced node to the replacing node.
Named slots are bound to their host node and are never transferred: this
node keeps its slot map, so if it is reattached elsewhere (as
$wrapNodeInElement does) its slots come with it, and if it stays
detached the slot subtrees are garbage-collected along with it. To move a
slot value onto another host, use $setSlot explicitly.
Type Parameters
N
N extends LexicalNode
Parameters
replaceWith
N
The node to replace this one with.
includeChildren?
boolean
Whether or not to transfer the children of this node to the replacing node.
Returns
N
Inherited from
resetOnCopyNodeFrom()
resetOnCopyNodeFrom(
originalNode):void
Defined in: packages/lexical/src/LexicalNode.ts:1154
Reset state in this copy of originalNode, if necessary
Parameters
originalNode
this
Returns
void
Inherited from
ElementNode.resetOnCopyNodeFrom
select()
select(
_anchorOffset?,_focusOffset?):RangeSelection
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:715
Parameters
_anchorOffset?
number
_focusOffset?
number
Returns
Inherited from
selectEnd()
selectEnd():
RangeSelection
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:764
Returns
Inherited from
selectNext()
selectNext(
anchorOffset?,focusOffset?):RangeSelection
Defined in: packages/lexical/src/LexicalNode.ts:2359
Moves selection to the next sibling of this node, at the specified offsets.
Parameters
anchorOffset?
number
The anchor offset for selection.
focusOffset?
number
The focus offset for selection
Returns
Inherited from
selectPrevious()
selectPrevious(
anchorOffset?,focusOffset?):RangeSelection
Defined in: packages/lexical/src/LexicalNode.ts:2330
Moves selection to the previous sibling of this node, at the specified offsets.
Parameters
anchorOffset?
number
The anchor offset for selection.
focusOffset?
number
The focus offset for selection
Returns
Inherited from
selectStart()
selectStart():
RangeSelection
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:760
Returns
Inherited from
setBackgroundColor()
setBackgroundColor(
newBackgroundColor):this
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:289
Parameters
newBackgroundColor
string | null
Returns
this
setColSpan()
setColSpan(
colSpan):this
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:236
Parameters
colSpan
number
Returns
this
setDirection()
setDirection(
direction):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:777
Parameters
direction
"ltr" | "rtl" | null
Returns
this
Inherited from
setFormat()
setFormat(
type):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:782
Parameters
type
Returns
this
Inherited from
setHeaderStyles()
setHeaderStyles(
headerState,mask?):this
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:256
Parameters
headerState
number
mask?
number = TableCellHeaderStates.BOTH
Returns
this
setIndent()
setIndent(
indentLevel):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:802
Parameters
indentLevel
number
Returns
this
Inherited from
setRowSpan()
setRowSpan(
rowSpan):this
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:246
Parameters
rowSpan
number
Returns
this
setStyle()
setStyle(
style):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:787
Parameters
style
string
Returns
this
Inherited from
setTextFormat()
setTextFormat(
type):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:792
Parameters
type
number
Returns
this
Inherited from
setTextStyle()
setTextStyle(
style):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:797
Parameters
style
string
Returns
this
Inherited from
setVerticalAlign()
setVerticalAlign(
newVerticalAlign):this
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:299
Parameters
newVerticalAlign
string | null | undefined
Returns
this
setWidth()
setWidth(
width):this
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:269
Parameters
width
number | undefined
Returns
this
splice()
splice(
start,deleteCount,nodesToInsert):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:807
Parameters
start
number
deleteCount
number
nodesToInsert
Returns
this
Inherited from
toggleHeaderStyle()
toggleHeaderStyle(
headerStateToToggle):this
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:305
Parameters
headerStateToToggle
number
Returns
this
updateDOM()
updateDOM(
prevNode):boolean
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:330
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
Inherited from
updateFromJSON()
updateFromJSON(
serializedNode):this
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:122
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
LexicalParseJSON<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);
}
}
The whole schema is applied, so a property the JSON omits is set to its schema default rather than left as it is — that is what lets the compact form omit a default-valued property and have parsing restore it. (A flat NodeState is the exception: it is applied only when present.) Pass the node's complete serialized form unless you mean to reset what you leave out.
Inherited from
clone()
staticclone(_data):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:1029
Clones this node, creating a new node with a different key and adding it to the EditorState (but not attaching it anywhere!). All nodes must implement this method.
Parameters
_data
unknown
Returns
Inherited from
getType()
staticgetType():string
Defined in: packages/lexical/src/LexicalNode.ts:1013
Returns the string type of this node. Every node must implement this and it MUST BE UNIQUE amongst nodes registered on the editor.
Returns
string
Inherited from
importJSON()
staticimportJSON(_serializedNode):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:1870
Controls how the this node is deserialized from JSON. This is usually boilerplate, but provides an abstraction between the node implementation and serialized interface that can be important if you ever make breaking changes to a node schema (by adding or removing properties). See Serialization & Deserialization.
Parameters
_serializedNode
Omit<SerializedLexicalNode & Partial<SerializedLexicalNode>, "$slots" | "children" | "version"> & object & Record<string, unknown>
Returns
Inherited from
transform()
statictransform(): ((node) =>void) |null
Defined in: packages/lexical/src/LexicalNode.ts:1934
Experimental
Registers the returned function as a transform on the node during Editor initialization. Most such use cases should be addressed via the LexicalEditor.registerNodeTransform API.
Experimental - use at your own risk.
Returns
((node) => void) | null
Inherited from
TableNode
Defined in: packages/lexical-table/src/LexicalTableNode.ts:406
Extends
Constructors
Constructor
new TableNode(
key?):TableNode
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:303
Parameters
key?
string
Returns
Inherited from
Properties
__colWidths
__colWidths: readonly
number[] |undefined=undefined
Defined in: packages/lexical-table/src/LexicalTableNode.ts:423
__frozenColumnCount
__frozenColumnCount:
number=0
Defined in: packages/lexical-table/src/LexicalTableNode.ts:417
__frozenRowCount
__frozenRowCount:
number=0
Defined in: packages/lexical-table/src/LexicalTableNode.ts:418
importDOM?
staticoptionalimportDOM?: () =>DOMConversionMap<any> |null
Defined in: packages/lexical/src/LexicalNode.ts:1161
Returns
DOMConversionMap<any> | null
Inherited from
Methods
$config()
$config():
BaseStaticNodeConfig&StaticNodeConfigAccessor<{$transform: { };extends: typeofLexicalNode;generated:GeneratedJSONFactory;json:NodeSerializationSchema<ElementNode, {direction?:"ltr"|"rtl"|null;format?:""|"left"|"start"|"center"|"right"|"end"|"justify";indent?:string|number;textFormat?:string|number;textStyle?:string; }>; }> &object&StaticNodeTypeAccessor<"table"> &StaticNodeConfigAccessor<{extends: typeofElementNode;generated:GeneratedJSONFactory;importDOM: {table: () =>object; };json:NodeSerializationSchema<TableNode, {colWidths?: readonly (string|number)[];frozenColumnCount?:string|number;frozenRowCount?:string|number;rowStriping?:boolean; }>; }>
Defined in: packages/lexical-table/src/LexicalTableNode.ts:425
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 & StaticNodeConfigAccessor<{ $transform: { }; extends: typeof LexicalNode; generated: GeneratedJSONFactory; json: NodeSerializationSchema<ElementNode, { direction?: "ltr" | "rtl" | null; format?: "" | "left" | "start" | "center" | "right" | "end" | "justify"; indent?: string | number; textFormat?: string | number; textStyle?: string; }>; }> & object & StaticNodeTypeAccessor<"table"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; generated: GeneratedJSONFactory; importDOM: { table: () => object; }; json: NodeSerializationSchema<TableNode, { colWidths?: readonly (string | number)[]; frozenColumnCount?: string | number; frozenRowCount?: string | number; rowStriping?: boolean; }>; }>
Example
class MyNode extends TextNode {
$config() {
return this.config('my-node', {extends: TextNode});
}
}
Inherited from
afterCloneFrom()
afterCloneFrom(
prevNode):void
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:329
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;
}
}
Inherited from
append()
append(...
nodesToAppend):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:774
Parameters
nodesToAppend
...LexicalNode[]
Returns
this
Inherited from
canBeEmpty()
canBeEmpty():
false
Defined in: packages/lexical-table/src/LexicalTableNode.ts:718
Returns
false
Inherited from
canIndent()
canIndent():
false
Defined in: packages/lexical-table/src/LexicalTableNode.ts:861
Returns
false
Inherited from
canInsertTextAfter()
canInsertTextAfter():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1078
Returns
boolean
Inherited from
ElementNode.canInsertTextAfter
canInsertTextBefore()
canInsertTextBefore():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1075
Returns
boolean
Inherited from
ElementNode.canInsertTextBefore
canMergeWhenEmpty()
canMergeWhenEmpty():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1121
Determines whether this node, when empty, can merge with a first block of nodes being inserted.
This method is specifically called in RangeSelection.insertNodes to determine merging behavior during nodes insertion.
Returns
boolean
Example
// In a ListItemNode or QuoteNode implementation:
canMergeWhenEmpty(): true {
return true;
}
Inherited from
canSelectBefore()
canSelectBefore():
true
Defined in: packages/lexical-table/src/LexicalTableNode.ts:857
Returns
true
clear()
clear():
this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:768
Returns
this
Inherited from
collapseAtStart()
collapseAtStart(
selection):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1058
Parameters
selection
Returns
boolean
Inherited from
config()
Call Signature
config<
Config>(type,config):AbstractStaticNodeConfigRecord<Config>
Defined in: packages/lexical/src/LexicalNode.ts:1065
This is a convenience method for $config that aids in type inference. See LexicalNode.$config for example usage.
An abstract base class that has no concrete node type may pass a
well-known symbol (by convention Symbol.for(<NodeClassName>)) instead of
a string type to declare configuration shared with its subclasses.
Type Parameters
Config
Config extends StaticNodeConfigValue<TableNode, string>
Parameters
type
symbol
config
Config
Returns
AbstractStaticNodeConfigRecord<Config>
Inherited from
Call Signature
config<
Type,Config>(type,config):StaticNodeConfigRecord<Type,Config>
Defined in: packages/lexical/src/LexicalNode.ts:1069
This is a convenience method for $config that aids in type inference. See LexicalNode.$config for example usage.
An abstract base class that has no concrete node type may pass a
well-known symbol (by convention Symbol.for(<NodeClassName>)) instead of
a string type to declare configuration shared with its subclasses.
Type Parameters
Type
Type extends string
Config
Config extends StaticNodeConfigValue<TableNode, Type>
Parameters
type
Type
config
Config
Returns
StaticNodeConfigRecord<Type, Config>
Inherited from
createDOM()
createDOM(
config,editor?):HTMLElement
Defined in: packages/lexical-table/src/LexicalTableNode.ts:489
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
editor?
Returns
HTMLElement
Inherited from
createParentElementNode()
createParentElementNode():
ElementNode
Defined in: packages/lexical/src/LexicalNode.ts:2312
The creation logic for any required parent. Should be implemented if isParentRequired returns true.
Returns
Inherited from
ElementNode.createParentElementNode
excludeFromCopy()
excludeFromCopy(
destination?):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1061
Parameters
destination?
"clone" | "html"
Returns
boolean
Inherited from
exportDOM()
exportDOM(
editor):DOMExportOutput
Defined in: packages/lexical-table/src/LexicalTableNode.ts:605
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
Returns
Inherited from
exportJSON()
Call Signature
exportJSON(
compact?):SerializedTableNode
Defined in: packages/lexical-table/src/LexicalTableNode.ts:407
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.
The base implementation writes every property the node's schema declares
(its own and those it inherits), reading each through its getter —
get<Prop> by default, or the name recorded with withAccessors. A getter
that returns undefined omits its property. Override this only for output
a schema can not describe, and call super.exportJSON(compact) when you do.
This may serialize the instance as-is, without resolving the latest version. A property declared with withField is read straight off the node, which is the optimization the serialization walk is built on — every node the walk reaches comes from the EditorState's node map and is already current, so it resolves nothing per node.
So on a reference that a getWritable() (any set<Prop>) has since
superseded, this writes pre-mutation values. Which properties do is not
something to rely on: a property whose accessor a subclass overrode still
goes through that accessor and resolves the latest, so one node can write
a current text beside a stale style. Call
node.getLatest().exportJSON() whenever you hold such a reference rather
than reasoning about which properties resolve.
This is a breaking change. Every property previously went through an
accessor, and every accessor resolves getLatest(), so a stale reference
exported current values.
Parameters
compact?
false
Write the compact form: omit a property the parser derives
rather than reads, one whose value is the schema default parsing would
restore, and the deprecated version. The two forms describe the same
document. A node that overrides this and ignores the flag simply keeps
writing the full form, which still parses.
Returns
Inherited from
Call Signature
exportJSON(
compact):SerializedPartial<SerializedTableNode>
Defined in: packages/lexical-table/src/LexicalTableNode.ts:408
The compact form omits properties, so what it returns is the partial
serialized type — every node-specific property optional — rather than the
full one. Passing a boolean whose value is not statically known selects
this overload too, which is right: neither form can be promised then.
Parameters
compact
boolean
Returns
SerializedPartial<SerializedTableNode>
See
Inherited from
extractWithChild()
extractWithChild(
child,selection,destination):boolean
Defined in: packages/lexical-table/src/LexicalTableNode.ts:467
Parameters
child
selection
BaseSelection | null
destination
"clone" | "html"
Returns
boolean
Inherited from
getAllTextNodes()
getAllTextNodes():
TextNode[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:420
Returns
TextNode[]
Inherited from
getCellNodeFromCords()
getCellNodeFromCords(
x,y,table):TableCellNode|null
Defined in: packages/lexical-table/src/LexicalTableNode.ts:793
Parameters
x
number
y
number
table
TableDOMTable
Returns
TableCellNode | null
getCellNodeFromCordsOrThrow()
getCellNodeFromCordsOrThrow(
x,y,table):TableCellNode
Defined in: packages/lexical-table/src/LexicalTableNode.ts:813
Parameters
x
number
y
number
table
TableDOMTable
Returns
getChildAtIndex()
Call Signature
getChildAtIndex(
index):LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:605
Returns the child of this node at the given index, or null if the index is out of range.
Parameters
index
number
Returns
LexicalNode | null
Inherited from
Call Signature
getChildAtIndex<
T>(index):T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:612
Type Parameters
T
T extends LexicalNode
Parameters
index
number
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getChildAtIndex(index) as T | null, and will
be removed in a future release. Call this method without a type
argument and narrow the result with a type guard instead.
Inherited from
getChildren()
Call Signature
getChildren():
LexicalNode[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:374
Returns the children of this node, in document order.
Returns
Inherited from
Call Signature
getChildren<
T>():T[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:381
Type Parameters
T
T extends LexicalNode
Returns
T[]
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getChildren() as T[], and will be
removed in a future release. Call this method without a type argument
and narrow the results with a type guard instead.
Inherited from
getChildrenKeys()
getChildrenKeys():
string[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:391
Returns
string[]
Inherited from
getChildrenSize()
getChildrenSize():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:400
Returns
number
Inherited from
getColumnCount()
getColumnCount():
number
Defined in: packages/lexical-table/src/LexicalTableNode.ts:865
Returns
number
getColWidths()
getColWidths(): readonly
number[] |undefined
Defined in: packages/lexical-table/src/LexicalTableNode.ts:454
Returns
readonly number[] | undefined
getCommonAncestor()
getCommonAncestor<
T>(node):T|null
Defined in: packages/lexical/src/LexicalNode.ts:1506
Type Parameters
T
T extends ElementNode = ElementNode
Parameters
node
the other node to find the common ancestor of.
Returns
T | null
Deprecated
Returns the closest common ancestor of this node and the provided one or null if one cannot be found.
Inherited from
getCordsFromCellNode()
getCordsFromCellNode(
tableCellNode,table):object
Defined in: packages/lexical-table/src/LexicalTableNode.ts:726
Parameters
tableCellNode
table
TableDOMTable
Returns
object
x
x:
number
y
y:
number
getDescendantByIndex()
Call Signature
getDescendantByIndex(
index):LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:505
Returns the deepest descendant corresponding to the child at the given index, or null if this node has no children.
Parameters
index
number
Returns
LexicalNode | null
Inherited from
ElementNode.getDescendantByIndex
Call Signature
getDescendantByIndex<
T>(index):T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:512
Type Parameters
T
T extends LexicalNode
Parameters
index
number
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getDescendantByIndex(index) as T | null, and
will be removed in a future release. Call this method without a type
argument and narrow the result with a type guard instead.
Inherited from
ElementNode.getDescendantByIndex
getDirection()
getDirection():
"ltr"|"rtl"|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:678
Returns
"ltr" | "rtl" | null
Inherited from
getDOMCellFromCords()
getDOMCellFromCords(
x,y,table):TableDOMCell|null
Defined in: packages/lexical-table/src/LexicalTableNode.ts:755
Parameters
x
number
y
number
table
TableDOMTable
Returns
TableDOMCell | null
getDOMCellFromCordsOrThrow()
getDOMCellFromCordsOrThrow(
x,y,table):TableDOMCell
Defined in: packages/lexical-table/src/LexicalTableNode.ts:779
Parameters
x
number
y
number
table
TableDOMTable
Returns
getDOMSlot()
getDOMSlot(
element):ElementDOMSlot<HTMLTableElement>
Defined in: packages/lexical-table/src/LexicalTableNode.ts:475
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>
Inherited from
getFirstChild()
Call Signature
getFirstChild():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:536
Returns the first child of this node, or null if it has no children.
Returns
LexicalNode | null
Inherited from
Call Signature
getFirstChild<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:543
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getFirstChild() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getFirstChildOrThrow()
Call Signature
getFirstChildOrThrow():
LexicalNode
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:552
Returns the first child of this node, or throws if it has no children.
Returns
Inherited from
ElementNode.getFirstChildOrThrow
Call Signature
getFirstChildOrThrow<
T>():T
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:559
Type Parameters
T
T extends LexicalNode
Returns
T
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getFirstChildOrThrow() as T, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getFirstChildOrThrow
getFirstDescendant()
Call Signature
getFirstDescendant():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:459
Returns the deepest first descendant of this node, or null if it has no children.
Descendant navigation is children-only by design: it feeds selectStart / selectEnd and selection, which must not see slots (slots are isolated).
Returns
LexicalNode | null
Inherited from
ElementNode.getFirstDescendant
Call Signature
getFirstDescendant<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:466
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getFirstDescendant() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getFirstDescendant
getFormat()
getFormat():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:355
Returns
number
Inherited from
getFormatFlags()
getFormatFlags(
type,alignWithFormat):number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:702
Returns the format flags applied to the node as a 32-bit integer.
Parameters
type
alignWithFormat
number | null
Returns
number
a number representing the TextFormatTypes applied to the node.
Inherited from
getFormatType()
getFormatType():
ElementFormatType
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:359
Returns
Inherited from
getFrozenColumns()
getFrozenColumns():
number
Defined in: packages/lexical-table/src/LexicalTableNode.ts:843
Returns
number
getFrozenRows()
getFrozenRows():
number
Defined in: packages/lexical-table/src/LexicalTableNode.ts:853
Returns
number
getIndent()
getIndent():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:367
Returns
number
Inherited from
getIndexWithinParent()
getIndexWithinParent():
number
Defined in: packages/lexical/src/LexicalNode.ts:1283
Returns the zero-based index of this node within the parent.
Returns
number
Inherited from
ElementNode.getIndexWithinParent
getKey()
getKey():
string
Defined in: packages/lexical/src/LexicalNode.ts:1275
Returns this nodes key.
Returns
string
Inherited from
getLastChild()
Call Signature
getLastChild():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:570
Returns the last child of this node, or null if it has no children.
Returns
LexicalNode | null
Inherited from
Call Signature
getLastChild<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:577
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getLastChild() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getLastChildOrThrow()
Call Signature
getLastChildOrThrow():
LexicalNode
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:586
Returns the last child of this node, or throws if it has no children.
Returns
Inherited from
ElementNode.getLastChildOrThrow
Call Signature
getLastChildOrThrow<
T>():T
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:593
Type Parameters
T
T extends LexicalNode
Returns
T
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getLastChildOrThrow() as T, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getLastChildOrThrow
getLastDescendant()
Call Signature
getLastDescendant():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:482
Returns the deepest last descendant of this node, or null if it has no children.
Returns
LexicalNode | null
Inherited from
Call Signature
getLastDescendant<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:489
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getLastDescendant() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getLatest()
getLatest():
this
Defined in: packages/lexical/src/LexicalNode.ts:1656
Returns the latest version of the node from the active EditorState. This is used to avoid getting values from stale node references.
Returns
this
Inherited from
getNextSibling()
Call Signature
getNextSibling():
LexicalNode|null
Defined in: packages/lexical/src/LexicalNode.ts:1462
Returns the node after this one in the same parent, or null if there is no such node.
Returns
LexicalNode | null
Inherited from
Call Signature
getNextSibling<
T>():T|null
Defined in: packages/lexical/src/LexicalNode.ts:1469
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getNextSibling() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getNextSiblings()
Call Signature
getNextSiblings():
LexicalNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1480
Returns all nodes after this one in the same parent, in document order.
Returns
Inherited from
Call Signature
getNextSiblings<
T>():T[]
Defined in: packages/lexical/src/LexicalNode.ts:1487
Type Parameters
T
T extends LexicalNode
Returns
T[]
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getNextSiblings() as T[], and will be
removed in a future release. Call this method without a type argument
and narrow the results with a type guard instead.
Inherited from
getNodesBetween()
getNodesBetween(
targetNode):LexicalNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1575
Returns a list of nodes that are between this node and the target node in the EditorState.
Parameters
targetNode
the node that marks the other end of the range of nodes to be returned.
Returns
Inherited from
getParent()
Call Signature
getParent():
ElementNode|null
Defined in: packages/lexical/src/LexicalNode.ts:1303
Returns the parent of this node, or null if none is found.
Returns
ElementNode | null
Inherited from
Call Signature
getParent<
T>():T|null
Defined in: packages/lexical/src/LexicalNode.ts:1310
Type Parameters
T
T extends ElementNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getParent() as T | null, and will be removed
in a future release. Call this method without a type argument and
narrow the result with a type guard instead.
Inherited from
getParentKeys()
getParentKeys():
string[]
Defined in: packages/lexical/src/LexicalNode.ts:1401
Returns a list of the keys of every ancestor of this node, all the way up to the RootNode.
Returns
string[]
Inherited from
getParentOrThrow()
Call Signature
getParentOrThrow():
ElementNode
Defined in: packages/lexical/src/LexicalNode.ts:1323
Returns the parent of this node, or throws if none is found.
Returns
Inherited from
Call Signature
getParentOrThrow<
T>():T
Defined in: packages/lexical/src/LexicalNode.ts:1330
Type Parameters
T
T extends ElementNode
Returns
T
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getParentOrThrow() as T, and will be removed
in a future release. Call this method without a type argument and
narrow the result with a type guard instead.
Inherited from
getParents()
getParents():
ElementNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1386
Returns a list of the every ancestor of this node, all the way up to the RootNode.
Returns
Inherited from
getPreviousSibling()
Call Signature
getPreviousSibling():
LexicalNode|null
Defined in: packages/lexical/src/LexicalNode.ts:1415
Returns the node before this one in the same parent, or null if there is no such node.
Returns
LexicalNode | null
Inherited from
ElementNode.getPreviousSibling
Call Signature
getPreviousSibling<
T>():T|null
Defined in: packages/lexical/src/LexicalNode.ts:1422
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getPreviousSibling() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getPreviousSibling
getPreviousSiblings()
Call Signature
getPreviousSiblings():
LexicalNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1433
Returns all nodes before this one in the same parent, in document order.
Returns
Inherited from
ElementNode.getPreviousSiblings
Call Signature
getPreviousSiblings<
T>():T[]
Defined in: packages/lexical/src/LexicalNode.ts:1440
Type Parameters
T
T extends LexicalNode
Returns
T[]
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getPreviousSiblings() as T[], and will be
removed in a future release. Call this method without a type argument
and narrow the results with a type guard instead.
Inherited from
ElementNode.getPreviousSiblings
getRowStriping()
getRowStriping():
boolean
Defined in: packages/lexical-table/src/LexicalTableNode.ts:827
Returns
boolean
getStyle()
getStyle():
string
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:363
Returns
string
Inherited from
getTextContent()
getTextContent():
string
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:640
Returns the text content of the node. Override this for custom nodes that should have a representation in plain text format (for copy + paste, for example)
Returns
string
Inherited from
getTextContentSize()
getTextContentSize():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:659
Returns the length of the string produced by calling getTextContent on this node.
Returns
number
Inherited from
ElementNode.getTextContentSize
getTextFormat()
getTextFormat():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:682
Returns
number
Inherited from
getTextStyle()
getTextStyle():
string
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:708
Returns
string
Inherited from
getTopLevelElement()
getTopLevelElement():
ElementNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:241
Returns the highest (in the EditorState tree) non-root ancestor of this node, or null if none is found. See $isRootOrShadowRoot for more information on which Elements comprise "roots".
Returns
ElementNode | null
Inherited from
ElementNode.getTopLevelElement
getTopLevelElementOrThrow()
getTopLevelElementOrThrow():
ElementNode
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:242
Returns the highest (in the EditorState tree) non-root ancestor of this node, or throws if none is found. See $isRootOrShadowRoot for more information on which Elements comprise "roots".
Returns
Inherited from
ElementNode.getTopLevelElementOrThrow
getType()
getType():
string
Defined in: packages/lexical/src/LexicalNode.ts:1186
Returns the string type of this node.
Returns
string
Inherited from
getWritable()
getWritable():
this
Defined in: packages/lexical/src/LexicalNode.ts:1677
Returns a mutable version of the node using $cloneWithProperties if necessary. Will throw an error if called outside of a Lexical Editor LexicalEditor.update callback.
Returns
this
Inherited from
hasFormat()
hasFormat(
type):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:686
Parameters
type
Returns
boolean
Inherited from
hasTextFormat()
hasTextFormat(
type):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:693
Parameters
type
Returns
boolean
Inherited from
insertAfter()
insertAfter(
nodeToInsert,restoreSelection?):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:2116
Inserts a node after this LexicalNode (as the next sibling).
Parameters
nodeToInsert
The node to insert after this one.
restoreSelection?
boolean = true
Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete.
Returns
Inherited from
insertBefore()
insertBefore(
nodeToInsert,restoreSelection?):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:2223
Inserts a node before this LexicalNode (as the previous sibling).
Parameters
nodeToInsert
The node to insert before this one.
restoreSelection?
boolean = true
Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete.
Returns
Inherited from
insertNewAfter()
insertNewAfter(
selection,restoreSelection?):LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1038
Parameters
selection
restoreSelection?
boolean
Returns
LexicalNode | null
Inherited from
is()
is(
object):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1523
Returns true if the provided node is the exact same one as this node, from Lexical's perspective. Always use this instead of referential equality.
Parameters
object
LexicalNode | null | undefined
the node to perform the equality comparison on.
Returns
boolean
Inherited from
isAttached()
isAttached():
boolean
Defined in: packages/lexical/src/LexicalNode.ts:1203
Returns true if there is a path between this node and the RootNode, false otherwise. This is a way of determining if the node is "attached" EditorState. Unattached nodes won't be reconciled and will ultimately be cleaned up by the Lexical GC.
Returns
boolean
Inherited from
isBefore()
isBefore(
targetNode):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1541
Returns true if this node logically precedes the target node in the editor state, false otherwise (including if there is no common ancestor).
Note that this notion of isBefore is based on post-order; a descendant node is always before its ancestors. See also $getCommonAncestor and $comparePointCaretNext for more flexible ways to determine the relative positions of nodes.
Parameters
targetNode
the node we're testing to see if it's after this one.
Returns
boolean
Inherited from
isDirty()
isDirty():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:410
Returns true if this node has been marked dirty during this update cycle.
Returns
boolean
Inherited from
isEmpty()
isEmpty():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:404
Returns
boolean
Inherited from
isInline()
isInline():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1086
If the method is overridden and returns true, ensure that canBeEmpty()
returns false for the inline node to work correctly
Returns
boolean
Inherited from
isLastChild()
isLastChild():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:415
Returns
boolean
Inherited from
isParentOf()
isParentOf(
targetNode):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1564
Returns true if this node is an ancestor of and distinct from the target node, false otherwise.
Parameters
targetNode
the would-be child node.
Returns
boolean
Inherited from
isParentRequired()
isParentRequired():
boolean
Defined in: packages/lexical/src/LexicalNode.ts:2304
Whether or not this node has a required parent. Used during copy + paste operations to normalize nodes that would otherwise be orphaned. For example, ListItemNodes without a ListNode parent or TextNodes with a ParagraphNode parent.
Returns
boolean
Inherited from
isSelected()
isSelected(
selection?):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1230
Returns true if this node is contained within the provided Selection., false otherwise. Relies on the algorithms implemented in BaseSelection.getNodes to determine what's included.
Parameters
selection?
BaseSelection | null
The selection that we want to determine if the node is in.
Returns
boolean
Inherited from
isShadowRoot()
isShadowRoot():
boolean
Defined in: packages/lexical-table/src/LexicalTableNode.ts:722
Returns
boolean
Inherited from
markDirty()
markDirty():
void
Defined in: packages/lexical/src/LexicalNode.ts:2387
Marks a node dirty, triggering transforms and forcing it to be reconciled during the update cycle.
Returns
void
Inherited from
remove()
remove(
preserveEmptyParent?):void
Defined in: packages/lexical/src/LexicalNode.ts:1948
Removes this LexicalNode from the EditorState. If the node isn't re-inserted somewhere, the Lexical garbage collector will eventually clean it up.
Parameters
preserveEmptyParent?
boolean
If falsy, the node's parent will be removed if it's empty after the removal operation. This is the default behavior, subject to other node heuristics such as ElementNode#canBeEmpty
Returns
void
Inherited from
replace()
replace<
N>(replaceWith,includeChildren?):N
Defined in: packages/lexical/src/LexicalNode.ts:1965
Replaces this LexicalNode with the provided node, optionally transferring the children of the replaced node to the replacing node.
Named slots are bound to their host node and are never transferred: this
node keeps its slot map, so if it is reattached elsewhere (as
$wrapNodeInElement does) its slots come with it, and if it stays
detached the slot subtrees are garbage-collected along with it. To move a
slot value onto another host, use $setSlot explicitly.
Type Parameters
N
N extends LexicalNode
Parameters
replaceWith
N
The node to replace this one with.
includeChildren?
boolean
Whether or not to transfer the children of this node to the replacing node.
Returns
N
Inherited from
resetOnCopyNodeFrom()
resetOnCopyNodeFrom(
originalNode):void
Defined in: packages/lexical/src/LexicalNode.ts:1154
Reset state in this copy of originalNode, if necessary
Parameters
originalNode
this
Returns
void
Inherited from
ElementNode.resetOnCopyNodeFrom
scaleDOMColWidths()
scaleDOMColWidths(
dom,scale):void
Defined in: packages/lexical-table/src/LexicalTableNode.ts:592
Parameters
dom
HTMLElement
scale
number
Returns
void
select()
select(
_anchorOffset?,_focusOffset?):RangeSelection
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:715
Parameters
_anchorOffset?
number
_focusOffset?
number
Returns
Inherited from
selectEnd()
selectEnd():
RangeSelection
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:764
Returns
Inherited from
selectNext()
selectNext(
anchorOffset?,focusOffset?):RangeSelection
Defined in: packages/lexical/src/LexicalNode.ts:2359
Moves selection to the next sibling of this node, at the specified offsets.
Parameters
anchorOffset?
number
The anchor offset for selection.
focusOffset?
number
The focus offset for selection
Returns
Inherited from
selectPrevious()
selectPrevious(
anchorOffset?,focusOffset?):RangeSelection
Defined in: packages/lexical/src/LexicalNode.ts:2330
Moves selection to the previous sibling of this node, at the specified offsets.
Parameters
anchorOffset?
number
The anchor offset for selection.
focusOffset?
number
The focus offset for selection
Returns
Inherited from
selectStart()
selectStart():
RangeSelection
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:760
Returns
Inherited from
setColWidths()
setColWidths(
colWidths):this
Defined in: packages/lexical-table/src/LexicalTableNode.ts:459
Parameters
colWidths
readonly number[] | undefined
Returns
this
setDirection()
setDirection(
direction):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:777
Parameters
direction
"ltr" | "rtl" | null
Returns
this
Inherited from
setFormat()
setFormat(
type):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:782
Parameters
type
Returns
this
Inherited from
setFrozenColumns()
setFrozenColumns(
columnCount):this
Defined in: packages/lexical-table/src/LexicalTableNode.ts:837
Parameters
columnCount
number
Returns
this
setFrozenRows()
setFrozenRows(
rowCount):this
Defined in: packages/lexical-table/src/LexicalTableNode.ts:847
Parameters
rowCount
number
Returns
this
setIndent()
setIndent(
indentLevel):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:802
Parameters
indentLevel
number
Returns
this
Inherited from
setRowStriping()
setRowStriping(
newRowStriping):this
Defined in: packages/lexical-table/src/LexicalTableNode.ts:831
Parameters
newRowStriping
boolean
Returns
this
setStyle()
setStyle(
style):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:787
Parameters
style
string
Returns
this
Inherited from
setTextFormat()
setTextFormat(
type):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:792
Parameters
type
number
Returns
this
Inherited from
setTextStyle()
setTextStyle(
style):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:797
Parameters
style
string
Returns
this
Inherited from
splice()
splice(
start,deleteCount,nodesToInsert):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:807
Parameters
start
number
deleteCount
number
nodesToInsert
Returns
this
Inherited from
updateDOM()
updateDOM(
prevNode,dom,config):boolean
Defined in: packages/lexical-table/src/LexicalTableNode.ts:571
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
Returns
boolean
Inherited from
updateFromJSON()
updateFromJSON(
serializedNode):this
Defined in: packages/lexical-table/src/LexicalTableNode.ts:409
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
LexicalParseJSON<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);
}
}
The whole schema is applied, so a property the JSON omits is set to its schema default rather than left as it is — that is what lets the compact form omit a default-valued property and have parsing restore it. (A flat NodeState is the exception: it is applied only when present.) Pass the node's complete serialized form unless you mean to reset what you leave out.
Inherited from
updateTableElement()
updateTableElement(
prevNode,tableElement,config):void
Defined in: packages/lexical-table/src/LexicalTableNode.ts:545
Parameters
prevNode
TableNode | null
tableElement
HTMLTableElement
config
Returns
void
updateTableWrapper()
updateTableWrapper(
prevNode,tableWrapper,tableElement,config):void
Defined in: packages/lexical-table/src/LexicalTableNode.ts:524
Parameters
prevNode
TableNode | null
tableWrapper
HTMLDivElement
tableElement
HTMLTableElement
config
Returns
void
clone()
staticclone(_data):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:1029
Clones this node, creating a new node with a different key and adding it to the EditorState (but not attaching it anywhere!). All nodes must implement this method.
Parameters
_data
unknown
Returns
Inherited from
getType()
staticgetType():string
Defined in: packages/lexical/src/LexicalNode.ts:1013
Returns the string type of this node. Every node must implement this and it MUST BE UNIQUE amongst nodes registered on the editor.
Returns
string
Inherited from
importJSON()
staticimportJSON(_serializedNode):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:1870
Controls how the this node is deserialized from JSON. This is usually boilerplate, but provides an abstraction between the node implementation and serialized interface that can be important if you ever make breaking changes to a node schema (by adding or removing properties). See Serialization & Deserialization.
Parameters
_serializedNode
Omit<SerializedLexicalNode & Partial<SerializedLexicalNode>, "$slots" | "children" | "version"> & object & Record<string, unknown>
Returns
Inherited from
transform()
statictransform(): ((node) =>void) |null
Defined in: packages/lexical/src/LexicalNode.ts:1934
Experimental
Registers the returned function as a transform on the node during Editor initialization. Most such use cases should be addressed via the LexicalEditor.registerNodeTransform API.
Experimental - use at your own risk.
Returns
((node) => void) | null
Inherited from
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
tableNodeKey
string
Returns
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
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
$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
$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
Returns
void
$setFocusCellForSelection()
$setFocusCellForSelection(
cell,ignoreStart?):boolean
Defined in: packages/lexical-table/src/LexicalTableObserver.ts:419
Parameters
cell
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:49
Extends
Constructors
Constructor
new TableRowNode(
height?,key?):TableRowNode
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:79
Parameters
height?
number | undefined
key?
string
Returns
Inherited from
Properties
importDOM?
staticoptionalimportDOM?: () =>DOMConversionMap<any> |null
Defined in: packages/lexical/src/LexicalNode.ts:1161
Returns
DOMConversionMap<any> | null
Inherited from
Methods
$config()
$config():
BaseStaticNodeConfig&StaticNodeConfigAccessor<{$transform: { };extends: typeofLexicalNode;generated:GeneratedJSONFactory;json:NodeSerializationSchema<ElementNode, {direction?:"ltr"|"rtl"|null;format?:""|"left"|"start"|"center"|"right"|"end"|"justify";indent?:string|number;textFormat?:string|number;textStyle?:string; }>; }> &object&StaticNodeTypeAccessor<"tablerow"> &StaticNodeConfigAccessor<{extends: typeofElementNode;generated:GeneratedJSONFactory;importDOM: {tr: () =>object; };json:NodeSerializationSchema<TableRowNode, {height?:string|number; }>; }>
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:63
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 & StaticNodeConfigAccessor<{ $transform: { }; extends: typeof LexicalNode; generated: GeneratedJSONFactory; json: NodeSerializationSchema<ElementNode, { direction?: "ltr" | "rtl" | null; format?: "" | "left" | "start" | "center" | "right" | "end" | "justify"; indent?: string | number; textFormat?: string | number; textStyle?: string; }>; }> & object & StaticNodeTypeAccessor<"tablerow"> & StaticNodeConfigAccessor<{ extends: typeof ElementNode; generated: GeneratedJSONFactory; importDOM: { tr: () => object; }; json: NodeSerializationSchema<TableRowNode, { height?: string | number; }>; }>
Example
class MyNode extends TextNode {
$config() {
return this.config('my-node', {extends: TextNode});
}
}
Inherited from
afterCloneFrom()
afterCloneFrom(
prevNode):void
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:329
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;
}
}
Inherited from
append()
append(...
nodesToAppend):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:774
Parameters
nodesToAppend
...LexicalNode[]
Returns
this
Inherited from
canBeEmpty()
canBeEmpty():
false
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:122
Returns
false
Inherited from
canIndent()
canIndent():
false
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:126
Returns
false
Inherited from
canInsertTextAfter()
canInsertTextAfter():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1078
Returns
boolean
Inherited from
ElementNode.canInsertTextAfter
canInsertTextBefore()
canInsertTextBefore():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1075
Returns
boolean
Inherited from
ElementNode.canInsertTextBefore
canMergeWhenEmpty()
canMergeWhenEmpty():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1121
Determines whether this node, when empty, can merge with a first block of nodes being inserted.
This method is specifically called in RangeSelection.insertNodes to determine merging behavior during nodes insertion.
Returns
boolean
Example
// In a ListItemNode or QuoteNode implementation:
canMergeWhenEmpty(): true {
return true;
}
Inherited from
clear()
clear():
this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:768
Returns
this
Inherited from
collapseAtStart()
collapseAtStart(
selection):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1058
Parameters
selection
Returns
boolean
Inherited from
config()
Call Signature
config<
Config>(type,config):AbstractStaticNodeConfigRecord<Config>
Defined in: packages/lexical/src/LexicalNode.ts:1065
This is a convenience method for $config that aids in type inference. See LexicalNode.$config for example usage.
An abstract base class that has no concrete node type may pass a
well-known symbol (by convention Symbol.for(<NodeClassName>)) instead of
a string type to declare configuration shared with its subclasses.
Type Parameters
Config
Config extends StaticNodeConfigValue<TableRowNode, string>
Parameters
type
symbol
config
Config
Returns
AbstractStaticNodeConfigRecord<Config>
Inherited from
Call Signature
config<
Type,Config>(type,config):StaticNodeConfigRecord<Type,Config>
Defined in: packages/lexical/src/LexicalNode.ts:1069
This is a convenience method for $config that aids in type inference. See LexicalNode.$config for example usage.
An abstract base class that has no concrete node type may pass a
well-known symbol (by convention Symbol.for(<NodeClassName>)) instead of
a string type to declare configuration shared with its subclasses.
Type Parameters
Type
Type extends string
Config
Config extends StaticNodeConfigValue<TableRowNode, Type>
Parameters
type
Type
config
Config
Returns
StaticNodeConfigRecord<Type, Config>
Inherited from
createDOM()
createDOM(
config):HTMLElement
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:84
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
Returns
HTMLElement
Inherited from
createParentElementNode()
createParentElementNode():
ElementNode
Defined in: packages/lexical/src/LexicalNode.ts:2312
The creation logic for any required parent. Should be implemented if isParentRequired returns true.
Returns
Inherited from
ElementNode.createParentElementNode
excludeFromCopy()
excludeFromCopy(
destination?):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1061
Parameters
destination?
"clone" | "html"
Returns
boolean
Inherited from
exportDOM()
exportDOM(
editor):DOMExportOutput
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:967
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
Returns
Inherited from
exportJSON()
Call Signature
exportJSON(
compact?):SerializedTableRowNode
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:50
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.
The base implementation writes every property the node's schema declares
(its own and those it inherits), reading each through its getter —
get<Prop> by default, or the name recorded with withAccessors. A getter
that returns undefined omits its property. Override this only for output
a schema can not describe, and call super.exportJSON(compact) when you do.
This may serialize the instance as-is, without resolving the latest version. A property declared with withField is read straight off the node, which is the optimization the serialization walk is built on — every node the walk reaches comes from the EditorState's node map and is already current, so it resolves nothing per node.
So on a reference that a getWritable() (any set<Prop>) has since
superseded, this writes pre-mutation values. Which properties do is not
something to rely on: a property whose accessor a subclass overrode still
goes through that accessor and resolves the latest, so one node can write
a current text beside a stale style. Call
node.getLatest().exportJSON() whenever you hold such a reference rather
than reasoning about which properties resolve.
This is a breaking change. Every property previously went through an
accessor, and every accessor resolves getLatest(), so a stale reference
exported current values.
Parameters
compact?
false
Write the compact form: omit a property the parser derives
rather than reads, one whose value is the schema default parsing would
restore, and the deprecated version. The two forms describe the same
document. A node that overrides this and ignores the flag simply keeps
writing the full form, which still parses.
Returns
Inherited from
Call Signature
exportJSON(
compact):SerializedPartial<SerializedTableRowNode>
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:51
The compact form omits properties, so what it returns is the partial
serialized type — every node-specific property optional — rather than the
full one. Passing a boolean whose value is not statically known selects
this overload too, which is right: neither form can be promised then.
Parameters
compact
boolean
Returns
SerializedPartial<SerializedTableRowNode>
See
Inherited from
extractWithChild()
extractWithChild(
child,selection,destination):boolean
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:96
Parameters
child
selection
BaseSelection | null
destination
"clone" | "html"
Returns
boolean
Inherited from
getAllTextNodes()
getAllTextNodes():
TextNode[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:420
Returns
TextNode[]
Inherited from
getChildAtIndex()
Call Signature
getChildAtIndex(
index):LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:605
Returns the child of this node at the given index, or null if the index is out of range.
Parameters
index
number
Returns
LexicalNode | null
Inherited from
Call Signature
getChildAtIndex<
T>(index):T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:612
Type Parameters
T
T extends LexicalNode
Parameters
index
number
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getChildAtIndex(index) as T | null, and will
be removed in a future release. Call this method without a type
argument and narrow the result with a type guard instead.
Inherited from
getChildren()
Call Signature
getChildren():
LexicalNode[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:374
Returns the children of this node, in document order.
Returns
Inherited from
Call Signature
getChildren<
T>():T[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:381
Type Parameters
T
T extends LexicalNode
Returns
T[]
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getChildren() as T[], and will be
removed in a future release. Call this method without a type argument
and narrow the results with a type guard instead.
Inherited from
getChildrenKeys()
getChildrenKeys():
string[]
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:391
Returns
string[]
Inherited from
getChildrenSize()
getChildrenSize():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:400
Returns
number
Inherited from
getCommonAncestor()
getCommonAncestor<
T>(node):T|null
Defined in: packages/lexical/src/LexicalNode.ts:1506
Type Parameters
T
T extends ElementNode = ElementNode
Parameters
node
the other node to find the common ancestor of.
Returns
T | null
Deprecated
Returns the closest common ancestor of this node and the provided one or null if one cannot be found.
Inherited from
getDescendantByIndex()
Call Signature
getDescendantByIndex(
index):LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:505
Returns the deepest descendant corresponding to the child at the given index, or null if this node has no children.
Parameters
index
number
Returns
LexicalNode | null
Inherited from
ElementNode.getDescendantByIndex
Call Signature
getDescendantByIndex<
T>(index):T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:512
Type Parameters
T
T extends LexicalNode
Parameters
index
number
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getDescendantByIndex(index) as T | null, and
will be removed in a future release. Call this method without a type
argument and narrow the result with a type guard instead.
Inherited from
ElementNode.getDescendantByIndex
getDirection()
getDirection():
"ltr"|"rtl"|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:678
Returns
"ltr" | "rtl" | null
Inherited from
getDOMSlot()
getDOMSlot(
element):ElementDOMSlot<HTMLElement>
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:964
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<HTMLElement>
Inherited from
getFirstChild()
Call Signature
getFirstChild():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:536
Returns the first child of this node, or null if it has no children.
Returns
LexicalNode | null
Inherited from
Call Signature
getFirstChild<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:543
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getFirstChild() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getFirstChildOrThrow()
Call Signature
getFirstChildOrThrow():
LexicalNode
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:552
Returns the first child of this node, or throws if it has no children.
Returns
Inherited from
ElementNode.getFirstChildOrThrow
Call Signature
getFirstChildOrThrow<
T>():T
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:559
Type Parameters
T
T extends LexicalNode
Returns
T
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getFirstChildOrThrow() as T, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getFirstChildOrThrow
getFirstDescendant()
Call Signature
getFirstDescendant():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:459
Returns the deepest first descendant of this node, or null if it has no children.
Descendant navigation is children-only by design: it feeds selectStart / selectEnd and selection, which must not see slots (slots are isolated).
Returns
LexicalNode | null
Inherited from
ElementNode.getFirstDescendant
Call Signature
getFirstDescendant<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:466
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getFirstDescendant() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getFirstDescendant
getFormat()
getFormat():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:355
Returns
number
Inherited from
getFormatFlags()
getFormatFlags(
type,alignWithFormat):number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:702
Returns the format flags applied to the node as a 32-bit integer.
Parameters
type
alignWithFormat
number | null
Returns
number
a number representing the TextFormatTypes applied to the node.
Inherited from
getFormatType()
getFormatType():
ElementFormatType
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:359
Returns
Inherited from
getHeight()
getHeight():
number|undefined
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:114
Returns
number | undefined
getIndent()
getIndent():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:367
Returns
number
Inherited from
getIndexWithinParent()
getIndexWithinParent():
number
Defined in: packages/lexical/src/LexicalNode.ts:1283
Returns the zero-based index of this node within the parent.
Returns
number
Inherited from
ElementNode.getIndexWithinParent
getKey()
getKey():
string
Defined in: packages/lexical/src/LexicalNode.ts:1275
Returns this nodes key.
Returns
string
Inherited from
getLastChild()
Call Signature
getLastChild():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:570
Returns the last child of this node, or null if it has no children.
Returns
LexicalNode | null
Inherited from
Call Signature
getLastChild<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:577
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getLastChild() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getLastChildOrThrow()
Call Signature
getLastChildOrThrow():
LexicalNode
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:586
Returns the last child of this node, or throws if it has no children.
Returns
Inherited from
ElementNode.getLastChildOrThrow
Call Signature
getLastChildOrThrow<
T>():T
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:593
Type Parameters
T
T extends LexicalNode
Returns
T
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getLastChildOrThrow() as T, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getLastChildOrThrow
getLastDescendant()
Call Signature
getLastDescendant():
LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:482
Returns the deepest last descendant of this node, or null if it has no children.
Returns
LexicalNode | null
Inherited from
Call Signature
getLastDescendant<
T>():T|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:489
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to element.getLastDescendant() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getLatest()
getLatest():
this
Defined in: packages/lexical/src/LexicalNode.ts:1656
Returns the latest version of the node from the active EditorState. This is used to avoid getting values from stale node references.
Returns
this
Inherited from
getNextSibling()
Call Signature
getNextSibling():
LexicalNode|null
Defined in: packages/lexical/src/LexicalNode.ts:1462
Returns the node after this one in the same parent, or null if there is no such node.
Returns
LexicalNode | null
Inherited from
Call Signature
getNextSibling<
T>():T|null
Defined in: packages/lexical/src/LexicalNode.ts:1469
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getNextSibling() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
getNextSiblings()
Call Signature
getNextSiblings():
LexicalNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1480
Returns all nodes after this one in the same parent, in document order.
Returns
Inherited from
Call Signature
getNextSiblings<
T>():T[]
Defined in: packages/lexical/src/LexicalNode.ts:1487
Type Parameters
T
T extends LexicalNode
Returns
T[]
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getNextSiblings() as T[], and will be
removed in a future release. Call this method without a type argument
and narrow the results with a type guard instead.
Inherited from
getNodesBetween()
getNodesBetween(
targetNode):LexicalNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1575
Returns a list of nodes that are between this node and the target node in the EditorState.
Parameters
targetNode
the node that marks the other end of the range of nodes to be returned.
Returns
Inherited from
getParent()
Call Signature
getParent():
ElementNode|null
Defined in: packages/lexical/src/LexicalNode.ts:1303
Returns the parent of this node, or null if none is found.
Returns
ElementNode | null
Inherited from
Call Signature
getParent<
T>():T|null
Defined in: packages/lexical/src/LexicalNode.ts:1310
Type Parameters
T
T extends ElementNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getParent() as T | null, and will be removed
in a future release. Call this method without a type argument and
narrow the result with a type guard instead.
Inherited from
getParentKeys()
getParentKeys():
string[]
Defined in: packages/lexical/src/LexicalNode.ts:1401
Returns a list of the keys of every ancestor of this node, all the way up to the RootNode.
Returns
string[]
Inherited from
getParentOrThrow()
Call Signature
getParentOrThrow():
ElementNode
Defined in: packages/lexical/src/LexicalNode.ts:1323
Returns the parent of this node, or throws if none is found.
Returns
Inherited from
Call Signature
getParentOrThrow<
T>():T
Defined in: packages/lexical/src/LexicalNode.ts:1330
Type Parameters
T
T extends ElementNode
Returns
T
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getParentOrThrow() as T, and will be removed
in a future release. Call this method without a type argument and
narrow the result with a type guard instead.
Inherited from
getParents()
getParents():
ElementNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1386
Returns a list of the every ancestor of this node, all the way up to the RootNode.
Returns
Inherited from
getPreviousSibling()
Call Signature
getPreviousSibling():
LexicalNode|null
Defined in: packages/lexical/src/LexicalNode.ts:1415
Returns the node before this one in the same parent, or null if there is no such node.
Returns
LexicalNode | null
Inherited from
ElementNode.getPreviousSibling
Call Signature
getPreviousSibling<
T>():T|null
Defined in: packages/lexical/src/LexicalNode.ts:1422
Type Parameters
T
T extends LexicalNode
Returns
T | null
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getPreviousSibling() as T | null, and will be
removed in a future release. Call this method without a type argument
and narrow the result with a type guard instead.
Inherited from
ElementNode.getPreviousSibling
getPreviousSiblings()
Call Signature
getPreviousSiblings():
LexicalNode[]
Defined in: packages/lexical/src/LexicalNode.ts:1433
Returns all nodes before this one in the same parent, in document order.
Returns
Inherited from
ElementNode.getPreviousSiblings
Call Signature
getPreviousSiblings<
T>():T[]
Defined in: packages/lexical/src/LexicalNode.ts:1440
Type Parameters
T
T extends LexicalNode
Returns
T[]
Deprecated
The type parameter is an unchecked and unsafe cast,
equivalent to node.getPreviousSiblings() as T[], and will be
removed in a future release. Call this method without a type argument
and narrow the results with a type guard instead.
Inherited from
ElementNode.getPreviousSiblings
getStyle()
getStyle():
string
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:363
Returns
string
Inherited from
getTextContent()
getTextContent():
string
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:640
Returns the text content of the node. Override this for custom nodes that should have a representation in plain text format (for copy + paste, for example)
Returns
string
Inherited from
getTextContentSize()
getTextContentSize():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:659
Returns the length of the string produced by calling getTextContent on this node.
Returns
number
Inherited from
ElementNode.getTextContentSize
getTextFormat()
getTextFormat():
number
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:682
Returns
number
Inherited from
getTextStyle()
getTextStyle():
string
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:708
Returns
string
Inherited from
getTopLevelElement()
getTopLevelElement():
ElementNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:241
Returns the highest (in the EditorState tree) non-root ancestor of this node, or null if none is found. See $isRootOrShadowRoot for more information on which Elements comprise "roots".
Returns
ElementNode | null
Inherited from
ElementNode.getTopLevelElement
getTopLevelElementOrThrow()
getTopLevelElementOrThrow():
ElementNode
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:242
Returns the highest (in the EditorState tree) non-root ancestor of this node, or throws if none is found. See $isRootOrShadowRoot for more information on which Elements comprise "roots".
Returns
Inherited from
ElementNode.getTopLevelElementOrThrow
getType()
getType():
string
Defined in: packages/lexical/src/LexicalNode.ts:1186
Returns the string type of this node.
Returns
string
Inherited from
getWritable()
getWritable():
this
Defined in: packages/lexical/src/LexicalNode.ts:1677
Returns a mutable version of the node using $cloneWithProperties if necessary. Will throw an error if called outside of a Lexical Editor LexicalEditor.update callback.
Returns
this
Inherited from
hasFormat()
hasFormat(
type):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:686
Parameters
type
Returns
boolean
Inherited from
hasTextFormat()
hasTextFormat(
type):boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:693
Parameters
type
Returns
boolean
Inherited from
insertAfter()
insertAfter(
nodeToInsert,restoreSelection?):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:2116
Inserts a node after this LexicalNode (as the next sibling).
Parameters
nodeToInsert
The node to insert after this one.
restoreSelection?
boolean = true
Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete.
Returns
Inherited from
insertBefore()
insertBefore(
nodeToInsert,restoreSelection?):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:2223
Inserts a node before this LexicalNode (as the previous sibling).
Parameters
nodeToInsert
The node to insert before this one.
restoreSelection?
boolean = true
Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete.
Returns
Inherited from
insertNewAfter()
insertNewAfter(
selection,restoreSelection?):LexicalNode|null
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1038
Parameters
selection
restoreSelection?
boolean
Returns
LexicalNode | null
Inherited from
is()
is(
object):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1523
Returns true if the provided node is the exact same one as this node, from Lexical's perspective. Always use this instead of referential equality.
Parameters
object
LexicalNode | null | undefined
the node to perform the equality comparison on.
Returns
boolean
Inherited from
isAttached()
isAttached():
boolean
Defined in: packages/lexical/src/LexicalNode.ts:1203
Returns true if there is a path between this node and the RootNode, false otherwise. This is a way of determining if the node is "attached" EditorState. Unattached nodes won't be reconciled and will ultimately be cleaned up by the Lexical GC.
Returns
boolean
Inherited from
isBefore()
isBefore(
targetNode):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1541
Returns true if this node logically precedes the target node in the editor state, false otherwise (including if there is no common ancestor).
Note that this notion of isBefore is based on post-order; a descendant node is always before its ancestors. See also $getCommonAncestor and $comparePointCaretNext for more flexible ways to determine the relative positions of nodes.
Parameters
targetNode
the node we're testing to see if it's after this one.
Returns
boolean
Inherited from
isDirty()
isDirty():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:410
Returns true if this node has been marked dirty during this update cycle.
Returns
boolean
Inherited from
isEmpty()
isEmpty():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:404
Returns
boolean
Inherited from
isInline()
isInline():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:1086
If the method is overridden and returns true, ensure that canBeEmpty()
returns false for the inline node to work correctly
Returns
boolean
Inherited from
isLastChild()
isLastChild():
boolean
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:415
Returns
boolean
Inherited from
isParentOf()
isParentOf(
targetNode):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1564
Returns true if this node is an ancestor of and distinct from the target node, false otherwise.
Parameters
targetNode
the would-be child node.
Returns
boolean
Inherited from
isParentRequired()
isParentRequired():
boolean
Defined in: packages/lexical/src/LexicalNode.ts:2304
Whether or not this node has a required parent. Used during copy + paste operations to normalize nodes that would otherwise be orphaned. For example, ListItemNodes without a ListNode parent or TextNodes with a ParagraphNode parent.
Returns
boolean
Inherited from
isSelected()
isSelected(
selection?):boolean
Defined in: packages/lexical/src/LexicalNode.ts:1230
Returns true if this node is contained within the provided Selection., false otherwise. Relies on the algorithms implemented in BaseSelection.getNodes to determine what's included.
Parameters
selection?
BaseSelection | null
The selection that we want to determine if the node is in.
Returns
boolean
Inherited from
isShadowRoot()
isShadowRoot():
boolean
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:104
Returns
boolean
Inherited from
markDirty()
markDirty():
void
Defined in: packages/lexical/src/LexicalNode.ts:2387
Marks a node dirty, triggering transforms and forcing it to be reconciled during the update cycle.
Returns
void
Inherited from
remove()
remove(
preserveEmptyParent?):void
Defined in: packages/lexical/src/LexicalNode.ts:1948
Removes this LexicalNode from the EditorState. If the node isn't re-inserted somewhere, the Lexical garbage collector will eventually clean it up.
Parameters
preserveEmptyParent?
boolean
If falsy, the node's parent will be removed if it's empty after the removal operation. This is the default behavior, subject to other node heuristics such as ElementNode#canBeEmpty
Returns
void
Inherited from
replace()
replace<
N>(replaceWith,includeChildren?):N
Defined in: packages/lexical/src/LexicalNode.ts:1965
Replaces this LexicalNode with the provided node, optionally transferring the children of the replaced node to the replacing node.
Named slots are bound to their host node and are never transferred: this
node keeps its slot map, so if it is reattached elsewhere (as
$wrapNodeInElement does) its slots come with it, and if it stays
detached the slot subtrees are garbage-collected along with it. To move a
slot value onto another host, use $setSlot explicitly.
Type Parameters
N
N extends LexicalNode
Parameters
replaceWith
N
The node to replace this one with.
includeChildren?
boolean
Whether or not to transfer the children of this node to the replacing node.
Returns
N
Inherited from
resetOnCopyNodeFrom()
resetOnCopyNodeFrom(
originalNode):void
Defined in: packages/lexical/src/LexicalNode.ts:1154
Reset state in this copy of originalNode, if necessary
Parameters
originalNode
this
Returns
void
Inherited from
ElementNode.resetOnCopyNodeFrom
select()
select(
_anchorOffset?,_focusOffset?):RangeSelection
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:715
Parameters
_anchorOffset?
number
_focusOffset?
number
Returns
Inherited from
selectEnd()
selectEnd():
RangeSelection
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:764
Returns
Inherited from
selectNext()
selectNext(
anchorOffset?,focusOffset?):RangeSelection
Defined in: packages/lexical/src/LexicalNode.ts:2359
Moves selection to the next sibling of this node, at the specified offsets.
Parameters
anchorOffset?
number
The anchor offset for selection.
focusOffset?
number
The focus offset for selection
Returns
Inherited from
selectPrevious()
selectPrevious(
anchorOffset?,focusOffset?):RangeSelection
Defined in: packages/lexical/src/LexicalNode.ts:2330
Moves selection to the previous sibling of this node, at the specified offsets.
Parameters
anchorOffset?
number
The anchor offset for selection.
focusOffset?
number
The focus offset for selection
Returns
Inherited from
selectStart()
selectStart():
RangeSelection
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:760
Returns
Inherited from
setDirection()
setDirection(
direction):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:777
Parameters
direction
"ltr" | "rtl" | null
Returns
this
Inherited from
setFormat()
setFormat(
type):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:782
Parameters
type
Returns
this
Inherited from
setHeight()
setHeight(
height?):this
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:108
Parameters
height?
number
Returns
this
setIndent()
setIndent(
indentLevel):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:802
Parameters
indentLevel
number
Returns
this
Inherited from
setStyle()
setStyle(
style):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:787
Parameters
style
string
Returns
this
Inherited from
setTextFormat()
setTextFormat(
type):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:792
Parameters
type
number
Returns
this
Inherited from
setTextStyle()
setTextStyle(
style):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:797
Parameters
style
string
Returns
this
Inherited from
splice()
splice(
start,deleteCount,nodesToInsert):this
Defined in: packages/lexical/src/nodes/LexicalElementNode.ts:807
Parameters
start
number
deleteCount
number
nodesToInsert
Returns
this
Inherited from
updateDOM()
updateDOM(
prevNode):boolean
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:118
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
Inherited from
updateFromJSON()
updateFromJSON(
serializedNode):this
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:52
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
LexicalParseJSON<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);
}
}
The whole schema is applied, so a property the JSON omits is set to its schema default rather than left as it is — that is what lets the compact form omit a default-valued property and have parsing restore it. (A flat NodeState is the exception: it is applied only when present.) Pass the node's complete serialized form unless you mean to reset what you leave out.
Inherited from
clone()
staticclone(_data):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:1029
Clones this node, creating a new node with a different key and adding it to the EditorState (but not attaching it anywhere!). All nodes must implement this method.
Parameters
_data
unknown
Returns
Inherited from
getType()
staticgetType():string
Defined in: packages/lexical/src/LexicalNode.ts:1013
Returns the string type of this node. Every node must implement this and it MUST BE UNIQUE amongst nodes registered on the editor.
Returns
string
Inherited from
importJSON()
staticimportJSON(_serializedNode):LexicalNode
Defined in: packages/lexical/src/LexicalNode.ts:1870
Controls how the this node is deserialized from JSON. This is usually boilerplate, but provides an abstraction between the node implementation and serialized interface that can be important if you ever make breaking changes to a node schema (by adding or removing properties). See Serialization & Deserialization.
Parameters
_serializedNode
Omit<SerializedLexicalNode & Partial<SerializedLexicalNode>, "$slots" | "children" | "version"> & object & Record<string, unknown>
Returns
Inherited from
transform()
statictransform(): ((node) =>void) |null
Defined in: packages/lexical/src/LexicalNode.ts:1934
Experimental
Registers the returned function as a transform on the node during Editor initialization. Most such use cases should be addressed via the LexicalEditor.registerNodeTransform API.
Experimental - use at your own risk.
Returns
((node) => void) | null
Inherited from
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
Implementation of
BaseSelection.clone
extract()
extract():
LexicalNode[]
Defined in: packages/lexical-table/src/LexicalTableSelection.ts:225
Returns
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
Implementation of
BaseSelection.getNodes
getShape()
getShape():
TableSelectionShape
Defined in: packages/lexical-table/src/LexicalTableSelection.ts:293
Returns
Deprecated
Use $computeTableMap and $computeTableCellRectBoundary directly.
getStartEndPoints()
Defined in: packages/lexical-table/src/LexicalTableSelection.ts:144
Returns
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
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
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:106
SerializedTableNode
SerializedTableNode =
Spread<{colWidths?: readonlynumber[];frozenColumnCount?:number;frozenRowCount?:number;rowStriping?:boolean; },SerializedElementNode>
Defined in: packages/lexical-table/src/LexicalTableNode.ts:66
SerializedTableRowNode
SerializedTableRowNode =
Spread<{height?:number; },SerializedElementNode>
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:35
TableCellHeaderState
TableCellHeaderState = typeof
TableCellHeaderStates[keyof typeofTableCellHeaderStates]
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:62
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
constINSERT_TABLE_COMMAND:LexicalCommand<InsertTableCommandPayload>
Defined in: packages/lexical-table/src/LexicalTableCommands.ts:24
TableCellHeaderStates
constTableCellHeaderStates:object
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:55
Type Declaration
BOTH
BOTH:
number
COLUMN
COLUMN:
number
NO_STATUS
NO_STATUS:
number
ROW
ROW:
number
TableExtension
constTableExtension: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
constTableImportExtension: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
constTableImportRules: (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
constTableRowSchema: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
constTableSchema: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
cellAMap
cellBMap
Returns
$computeTableMap()
$computeTableMap(
tableNode,cellA,cellB): [TableMapType,TableMapValueType,TableMapValueType]
Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1069
Parameters
tableNode
cellA
cellB
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
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:500
Parameters
headerState?
number = TableCellHeaderStates.NO_STATUS
colSpan?
number = 1
width?
number
Returns
$createTableNode()
$createTableNode():
TableNode
Defined in: packages/lexical-table/src/LexicalTableNode.ts:933
Returns
$createTableNodeWithDimensions()
$createTableNodeWithDimensions(
rowCount,columnCount,includeHeaders?):TableNode
Defined in: packages/lexical-table/src/LexicalTableUtils.ts:53
Parameters
rowCount
number
columnCount
number
includeHeaders?
InsertTableCommandPayloadHeaders = true
Returns
$createTableRowNode()
$createTableRowNode(
height?):TableRowNode
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:145
Parameters
height?
number
Returns
$createTableSelection()
$createTableSelection():
TableSelection
Defined in: packages/lexical-table/src/LexicalTableSelection.ts:426
Returns
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
anchorCell
focusCell
Returns
$deleteTableColumn()
$deleteTableColumn(
tableNode,targetIndex):TableNode
Defined in: packages/lexical-table/src/LexicalTableUtils.ts:606
Parameters
tableNode
targetIndex
number
Returns
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
Returns
TableCellNode | null
$findTableNode()
$findTableNode(
node):TableNode|null
Defined in: packages/lexical-table/src/LexicalTableSelectionHelpers.ts:2117
Parameters
node
Returns
TableNode | null
$getElementForTableNode()
$getElementForTableNode(
editor,tableNode):TableDOMTable
Defined in: packages/lexical-table/src/LexicalTableNode.ts:882
Parameters
editor
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
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
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
Returns
number
$getTableNodeFromLexicalNodeOrThrow()
$getTableNodeFromLexicalNodeOrThrow(
startingNode):TableNode
Defined in: packages/lexical-table/src/LexicalTableUtils.ts:119
Parameters
startingNode
Returns
$getTableRowIndexFromTableCellNode()
$getTableRowIndexFromTableCellNode(
tableCellNode):number
Defined in: packages/lexical-table/src/LexicalTableUtils.ts:131
Parameters
tableCellNode
Returns
number
$getTableRowNodeFromTableCellNodeOrThrow()
$getTableRowNodeFromTableCellNodeOrThrow(
startingNode):TableRowNode
Defined in: packages/lexical-table/src/LexicalTableUtils.ts:107
Parameters
startingNode
Returns
$insertTableColumn()
$insertTableColumn(
tableNode,targetIndex,shouldInsertAfter?,columnCount,table):TableNode
Defined in: packages/lexical-table/src/LexicalTableUtils.ts:389
Parameters
tableNode
targetIndex
number
shouldInsertAfter?
boolean = true
columnCount
number
table
TableDOMTable
Returns
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
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
targetIndex
number
shouldInsertAfter?
boolean = true
rowCount
number
table
TableDOMTable
Returns
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
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:367
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
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:373
Parameters
editor?
LexicalEditor = ...
Returns
boolean
$isTableCellNode()
$isTableCellNode(
node):node is TableCellNode
Defined in: packages/lexical-table/src/LexicalTableCellNode.ts:508
Parameters
node
LexicalNode | null | undefined
Returns
node is TableCellNode
$isTableNode()
$isTableNode(
node):node is TableNode
Defined in: packages/lexical-table/src/LexicalTableNode.ts:937
Parameters
node
LexicalNode | null | undefined
Returns
node is TableNode
$isTableRowNode()
$isTableRowNode(
node):node is TableRowNode
Defined in: packages/lexical-table/src/LexicalTableRowNode.ts:149
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
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
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
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
indexToDelete
number
Returns
$setTableColumnIsHeader()
$setTableColumnIsHeader(
tableNode,columnIndex,isHeader):void
Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1680
Parameters
tableNode
columnIndex
number
isHeader
boolean
Returns
void
$setTableRowIsHeader()
$setTableRowIsHeader(
tableNode,rowIndex,isHeader):void
Defined in: packages/lexical-table/src/LexicalTableUtils.ts:1652
Parameters
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
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
element
HTMLElement
editor
hasTabHandler
boolean
tableObservers
TableObservers
Returns
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
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
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
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
hasTabHandler?
boolean = true
Returns
() => void
setScrollableTablesActive()
setScrollableTablesActive(
editor,active):void
Defined in: packages/lexical-table/src/LexicalTableNode.ts:389
Parameters
editor
active
boolean
Returns
void