Skip to main content

@lexical/react/LexicalHorizontalRuleNode

Classes​

HorizontalRuleNode​

Defined in: packages/lexical-react/src/LexicalHorizontalRuleNode.tsx:83

Deprecated​

A pure Lexical implementation is available in @lexical/extension as HorizontalRuleExtension

Extends​

Constructors​

Constructor​

new HorizontalRuleNode(key?): HorizontalRuleNode

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:41

Parameters​
key?​

string

Returns​

HorizontalRuleNode

Inherited from​

HorizontalRuleNode.constructor

Properties​

importDOM?​

static optional importDOM?: () => DOMConversionMap<any> | null

Defined in: packages/lexical/src/LexicalNode.ts:1162

Returns​

DOMConversionMap<any> | null

Inherited from​

HorizontalRuleNode.importDOM

Methods​

$config()​

$config(): BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"horizontalrule"> & StaticNodeConfigAccessor<{ extends: typeof DecoratorNode; importDOM: { hr: () => object; }; }> & object & StaticNodeConfigAccessor<{ extends: typeof HorizontalRuleNode; importDOM: { hr: () => object; }; }>

Defined in: packages/lexical-react/src/LexicalHorizontalRuleNode.tsx:84

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

Returns​

BaseStaticNodeConfig & object & StaticNodeTypeAccessor<"horizontalrule"> & StaticNodeConfigAccessor<{ extends: typeof DecoratorNode; importDOM: { hr: () => object; }; }> & object & StaticNodeConfigAccessor<{ extends: typeof HorizontalRuleNode; importDOM: { hr: () => object; }; }>

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

HorizontalRuleNode.$config

afterCloneFrom()​

afterCloneFrom(prevNode): void

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:51

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

Parameters​
prevNode​

this

Returns​

void

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

HorizontalRuleNode.afterCloneFrom

config()​
Call Signature​

config<Config>(type, config): AbstractStaticNodeConfigRecord<Config>

Defined in: packages/lexical/src/LexicalNode.ts:1066

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<HorizontalRuleNode, string>

Parameters​
type​

symbol

config​

Config

Returns​

AbstractStaticNodeConfigRecord<Config>

Inherited from​

HorizontalRuleNode.config

Call Signature​

config<Type, Config>(type, config): StaticNodeConfigRecord<Type, Config>

Defined in: packages/lexical/src/LexicalNode.ts:1070

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<HorizontalRuleNode, Type>

Parameters​
type​

Type

config​

Config

Returns​

StaticNodeConfigRecord<Type, Config>

Inherited from​

HorizontalRuleNode.config

createDOM()​

createDOM(config): HTMLElement

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:80

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

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

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

Parameters​
config​

EditorConfig

Returns​

HTMLElement

Inherited from​

HorizontalRuleNode.createDOM

createParentElementNode()​

createParentElementNode(): ElementNode

Defined in: packages/lexical/src/LexicalNode.ts:2294

The creation logic for any required parent. Should be implemented if isParentRequired returns true.

Returns​

ElementNode

Inherited from​

HorizontalRuleNode.createParentElementNode

decorate()​

decorate(): Element

Defined in: packages/lexical-react/src/LexicalHorizontalRuleNode.tsx:100

The returned value is added to the LexicalEditor._decorators

Returns​

Element

Overrides​

HorizontalRuleNode.decorate

exportDOM()​

exportDOM(): DOMExportOutput

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:76

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.

Returns​

DOMExportOutput

Inherited from​

HorizontalRuleNode.exportDOM

exportJSON()​
Call Signature​

exportJSON(compact?): SerializedLexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:1818

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​

SerializedLexicalNode

Inherited from​

HorizontalRuleNode.exportJSON

Call Signature​

exportJSON(compact): SerializedPartial<SerializedLexicalNode>

Defined in: packages/lexical/src/LexicalNode.ts:1827

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

See​

SerializedPartial

Inherited from​

HorizontalRuleNode.exportJSON

getDOMSlot()​

getDOMSlot(element): DOMSlot<HTMLElement>

Defined in: packages/lexical/src/LexicalNode.ts:1765

Experimental

Returns a DOMSlot pointing at the content-bearing element of this node's DOM. The default returns a slot wrapping the keyed DOM as-is.

Override this when createDOM returns a wrapper around the content-bearing element (e.g. <span><br/></span> for a styled line break), so selection / reconciliation logic can target the inner element.

ElementNode overrides this to return an ElementDOMSlot with children-management semantics (used by the reconciler to place managed children).

Parameters​
element​

HTMLElement

Returns​

DOMSlot<HTMLElement>

Inherited from​

HorizontalRuleNode.getDOMSlot

getIndexWithinParent()​

getIndexWithinParent(): number

Defined in: packages/lexical/src/LexicalNode.ts:1284

Returns the zero-based index of this node within the parent.

Returns​

number

Inherited from​

HorizontalRuleNode.getIndexWithinParent

getKey()​

getKey(): string

Defined in: packages/lexical/src/LexicalNode.ts:1276

Returns this nodes key.

Returns​

string

Inherited from​

HorizontalRuleNode.getKey

getLatest()​

getLatest(): this

Defined in: packages/lexical/src/LexicalNode.ts:1638

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​

HorizontalRuleNode.getLatest

getNextSibling()​
Call Signature​

getNextSibling(): LexicalNode | null

Defined in: packages/lexical/src/LexicalNode.ts:1463

Returns the node after this one in the same parent, or null if there is no such node.

Returns​

LexicalNode | null

Inherited from​

HorizontalRuleNode.getNextSibling

Call Signature​

getNextSibling<T>(): T | null

Defined in: packages/lexical/src/LexicalNode.ts:1470

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​

HorizontalRuleNode.getNextSibling

getNextSiblings()​
Call Signature​

getNextSiblings(): LexicalNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1481

Returns all nodes after this one in the same parent, in document order.

Returns​

LexicalNode[]

Inherited from​

HorizontalRuleNode.getNextSiblings

Call Signature​

getNextSiblings<T>(): T[]

Defined in: packages/lexical/src/LexicalNode.ts:1488

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​

HorizontalRuleNode.getNextSiblings

getNodesBetween()​

getNodesBetween(targetNode): LexicalNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1557

Returns a list of nodes that are between this node and the target node in the EditorState.

Parameters​
targetNode​

LexicalNode

the node that marks the other end of the range of nodes to be returned.

Returns​

LexicalNode[]

Inherited from​

HorizontalRuleNode.getNodesBetween

getParent()​
Call Signature​

getParent(): ElementNode | null

Defined in: packages/lexical/src/LexicalNode.ts:1304

Returns the parent of this node, or null if none is found.

Returns​

ElementNode | null

Inherited from​

HorizontalRuleNode.getParent

Call Signature​

getParent<T>(): T | null

Defined in: packages/lexical/src/LexicalNode.ts:1311

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​

HorizontalRuleNode.getParent

getParentKeys()​

getParentKeys(): string[]

Defined in: packages/lexical/src/LexicalNode.ts:1402

Returns a list of the keys of every ancestor of this node, all the way up to the RootNode.

Returns​

string[]

Inherited from​

HorizontalRuleNode.getParentKeys

getParentOrThrow()​
Call Signature​

getParentOrThrow(): ElementNode

Defined in: packages/lexical/src/LexicalNode.ts:1324

Returns the parent of this node, or throws if none is found.

Returns​

ElementNode

Inherited from​

HorizontalRuleNode.getParentOrThrow

Call Signature​

getParentOrThrow<T>(): T

Defined in: packages/lexical/src/LexicalNode.ts:1331

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​

HorizontalRuleNode.getParentOrThrow

getParents()​

getParents(): ElementNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1387

Returns a list of the every ancestor of this node, all the way up to the RootNode.

Returns​

ElementNode[]

Inherited from​

HorizontalRuleNode.getParents

getPreviousSibling()​
Call Signature​

getPreviousSibling(): LexicalNode | null

Defined in: packages/lexical/src/LexicalNode.ts:1416

Returns the node before this one in the same parent, or null if there is no such node.

Returns​

LexicalNode | null

Inherited from​

HorizontalRuleNode.getPreviousSibling

Call Signature​

getPreviousSibling<T>(): T | null

Defined in: packages/lexical/src/LexicalNode.ts:1423

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​

HorizontalRuleNode.getPreviousSibling

getPreviousSiblings()​
Call Signature​

getPreviousSiblings(): LexicalNode[]

Defined in: packages/lexical/src/LexicalNode.ts:1434

Returns all nodes before this one in the same parent, in document order.

Returns​

LexicalNode[]

Inherited from​

HorizontalRuleNode.getPreviousSiblings

Call Signature​

getPreviousSiblings<T>(): T[]

Defined in: packages/lexical/src/LexicalNode.ts:1441

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​

HorizontalRuleNode.getPreviousSiblings

getTextContent()​

getTextContent(): string

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:86

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​

HorizontalRuleNode.getTextContent

getTextContentSize()​

getTextContentSize(): number

Defined in: packages/lexical/src/LexicalNode.ts:1708

Returns the length of the string produced by calling getTextContent on this node.

Returns​

number

Inherited from​

HorizontalRuleNode.getTextContentSize

getTopLevelElement()​

getTopLevelElement(): ElementNode | HorizontalRuleNode | null

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:24

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 | HorizontalRuleNode | null

Inherited from​

HorizontalRuleNode.getTopLevelElement

getTopLevelElementOrThrow()​

getTopLevelElementOrThrow(): ElementNode | HorizontalRuleNode

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:25

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​

ElementNode | HorizontalRuleNode

Inherited from​

HorizontalRuleNode.getTopLevelElementOrThrow

getType()​

getType(): string

Defined in: packages/lexical/src/LexicalNode.ts:1187

Returns the string type of this node.

Returns​

string

Inherited from​

HorizontalRuleNode.getType

getWritable()​

getWritable(): this

Defined in: packages/lexical/src/LexicalNode.ts:1659

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​

HorizontalRuleNode.getWritable

insertAfter()​

insertAfter(nodeToInsert, restoreSelection?): LexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:2098

Inserts a node after this LexicalNode (as the next sibling).

Parameters​
nodeToInsert​

LexicalNode

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​

LexicalNode

Inherited from​

HorizontalRuleNode.insertAfter

insertBefore()​

insertBefore(nodeToInsert, restoreSelection?): LexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:2205

Inserts a node before this LexicalNode (as the previous sibling).

Parameters​
nodeToInsert​

LexicalNode

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​

LexicalNode

Inherited from​

HorizontalRuleNode.insertBefore

is()​

is(object): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1505

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​

HorizontalRuleNode.is

isAttached()​

isAttached(): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1204

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​

HorizontalRuleNode.isAttached

isBefore()​

isBefore(targetNode): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1523

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​

LexicalNode

the node we're testing to see if it's after this one.

Returns​

boolean

Inherited from​

HorizontalRuleNode.isBefore

isDirty()​

isDirty(): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1627

Returns true if this node has been marked dirty during this update cycle.

Returns​

boolean

Inherited from​

HorizontalRuleNode.isDirty

isInline()​

isInline(): false

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:90

Returns​

false

Inherited from​

HorizontalRuleNode.isInline

isIsolated()​

isIsolated(): boolean

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:85

Whether this decorator is isolated from caret interaction: an isolated decorator can not be traversed, extended over, selected as a node, or deleted by an adjacent caret operation. A caret that reaches one stops there, so an inline isolated decorator is only reachable by pointer.

Defaults to false, which lets the caret step over the decorator (and select it, when DecoratorNode.isKeyboardSelectable is also true).

Returns​

boolean

Inherited from​

HorizontalRuleNode.isIsolated

isKeyboardSelectable()​

isKeyboardSelectable(): boolean

Defined in: packages/lexical/src/nodes/LexicalDecoratorNode.ts:93

Returns​

boolean

Inherited from​

HorizontalRuleNode.isKeyboardSelectable

isParentOf()​

isParentOf(targetNode): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1546

Returns true if this node is an ancestor of and distinct from the target node, false otherwise.

Parameters​
targetNode​

LexicalNode

the would-be child node.

Returns​

boolean

Inherited from​

HorizontalRuleNode.isParentOf

isParentRequired()​

isParentRequired(): boolean

Defined in: packages/lexical/src/LexicalNode.ts:2286

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​

HorizontalRuleNode.isParentRequired

isSelected()​

isSelected(selection?): boolean

Defined in: packages/lexical/src/LexicalNode.ts:1231

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​

HorizontalRuleNode.isSelected

markDirty()​

markDirty(): void

Defined in: packages/lexical/src/LexicalNode.ts:2369

Marks a node dirty, triggering transforms and forcing it to be reconciled during the update cycle.

Returns​

void

Inherited from​

HorizontalRuleNode.markDirty

remove()​

remove(preserveEmptyParent?): void

Defined in: packages/lexical/src/LexicalNode.ts:1930

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​

HorizontalRuleNode.remove

replace()​

replace<N>(replaceWith, includeChildren?): N

Defined in: packages/lexical/src/LexicalNode.ts:1947

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​

HorizontalRuleNode.replace

resetOnCopyNodeFrom()​

resetOnCopyNodeFrom(originalNode): void

Defined in: packages/lexical/src/LexicalNode.ts:1155

Reset state in this copy of originalNode, if necessary

Parameters​
originalNode​

this

Returns​

void

Inherited from​

HorizontalRuleNode.resetOnCopyNodeFrom

selectEnd()​

selectEnd(): RangeSelection

Defined in: packages/lexical/src/LexicalNode.ts:2302

Returns​

RangeSelection

Inherited from​

HorizontalRuleNode.selectEnd

selectNext()​

selectNext(anchorOffset?, focusOffset?): RangeSelection

Defined in: packages/lexical/src/LexicalNode.ts:2341

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​

RangeSelection

Inherited from​

HorizontalRuleNode.selectNext

selectPrevious()​

selectPrevious(anchorOffset?, focusOffset?): RangeSelection

Defined in: packages/lexical/src/LexicalNode.ts:2312

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​

RangeSelection

Inherited from​

HorizontalRuleNode.selectPrevious

selectStart()​

selectStart(): RangeSelection

Defined in: packages/lexical/src/LexicalNode.ts:2298

Returns​

RangeSelection

Inherited from​

HorizontalRuleNode.selectStart

updateDOM()​

updateDOM(): boolean

Defined in: packages/lexical-extension/src/HorizontalRuleExtension.ts:94

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.

Returns​

boolean

Inherited from​

HorizontalRuleNode.updateDOM

updateFromJSON()​

updateFromJSON(serializedNode): this

Defined in: packages/lexical/src/LexicalNode.ts:1898

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

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​

HorizontalRuleNode.updateFromJSON

clone()​

static clone(_data): LexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:1030

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​

LexicalNode

Inherited from​

HorizontalRuleNode.clone

getType()​

static getType(): string

Defined in: packages/lexical/src/LexicalNode.ts:1014

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​

HorizontalRuleNode.getType

importJSON()​

static importJSON(_serializedNode): LexicalNode

Defined in: packages/lexical/src/LexicalNode.ts:1852

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​

LexicalNode

Inherited from​

HorizontalRuleNode.importJSON

transform()​

static transform(): ((node) => void) | null

Defined in: packages/lexical/src/LexicalNode.ts:1916

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​

HorizontalRuleNode.transform

Functions​

$createHorizontalRuleNode()​

$createHorizontalRuleNode(): HorizontalRuleNode

Defined in: packages/lexical-react/src/LexicalHorizontalRuleNode.tsx:112

Returns​

HorizontalRuleNode

Deprecated​

A pure Lexical implementation is available in @lexical/extension as HorizontalRuleExtension

References​

$isHorizontalRuleNode​

Re-exports $isHorizontalRuleNode


INSERT_HORIZONTAL_RULE_COMMAND​

Re-exports INSERT_HORIZONTAL_RULE_COMMAND


SerializedHorizontalRuleNode​

Re-exports SerializedHorizontalRuleNode