Class: DecoratorBlockNode
@lexical/react/LexicalDecoratorBlockNode.DecoratorBlockNode
Hierarchy
-
DecoratorNode
<JSX.Element
>↳
DecoratorBlockNode
Constructors
constructor
• new DecoratorBlockNode(format?
, key?
): DecoratorBlockNode
Parameters
Name | Type |
---|---|
format? | ElementFormatType |
key? | string |
Returns
Overrides
Defined in
packages/lexical-react/src/LexicalDecoratorBlockNode.ts:29
Properties
__format
• __format: ElementFormatType
Defined in
packages/lexical-react/src/LexicalDecoratorBlockNode.ts:27
constructor
• constructor: KlassConstructor
<(key?
: string
) => DecoratorNode
<Element
>>
Inherited from
DecoratorNode.constructor
Defined in
packages/lexical/src/nodes/LexicalDecoratorNode.ts:27
importDOM
▪ Static
Optional
importDOM: () => null
| DOMConversionMap
<any
>
Type declaration
▸ (): null
| DOMConversionMap
<any
>
Returns
null
| DOMConversionMap
<any
>
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:270
Methods
afterCloneFrom
▸ afterCloneFrom(prevNode
): void
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
Name | Type |
---|---|
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
Defined in
packages/lexical/src/LexicalNode.ts:263
canIndent
▸ canIndent(): false
Returns
false
Defined in
packages/lexical-react/src/LexicalDecoratorBlockNode.ts:42
createDOM
▸ createDOM(): HTMLElement
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 lifecyle.
Returns
HTMLElement
Overrides
Defined in
packages/lexical-react/src/LexicalDecoratorBlockNode.ts:46
createParentElementNode
▸ createParentElementNode(): ElementNode
The creation logic for any required parent. Should be implemented if isParentRequired returns true.
Returns
Inherited from
DecoratorNode.createParentElementNode
Defined in
packages/lexical/src/LexicalNode.ts:1099
decorate
▸ decorate(editor
, config
): Element
The returned value is added to the LexicalEditor._decorators
Parameters
Name | Type |
---|---|
editor | LexicalEditor |
config | EditorConfig |
Returns
Element
Inherited from
Defined in
packages/lexical/src/nodes/LexicalDecoratorNode.ts:35
exportDOM
▸ exportDOM(editor
): DOMExportOutput
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
Name | Type |
---|---|
editor | LexicalEditor |
Returns
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:850
exportJSON
▸ exportJSON(): SerializedDecoratorBlockNode
Controls how the this node is serialized to JSON. This is important for copy and paste between Lexical editors sharing the same namespace. It's also important if you're serializing to JSON for persistent storage somewhere. See Serialization & Deserialization.
Returns
Overrides
Defined in
packages/lexical-react/src/LexicalDecoratorBlockNode.ts:34
getCommonAncestor
▸ getCommonAncestor<T
>(node
): null
| T
Returns the closest common ancestor of this node and the provided one or null if one cannot be found.
Type parameters
Name | Type |
---|---|
T | extends ElementNode = ElementNode |
Parameters
Name | Type | Description |
---|---|---|
node | LexicalNode | the other node to find the common ancestor of. |
Returns
null
| T
Inherited from
DecoratorNode.getCommonAncestor
Defined in
packages/lexical/src/LexicalNode.ts:558
getIndexWithinParent
▸ getIndexWithinParent(): number
Returns the zero-based index of this node within the parent.
Returns
number
Inherited from
DecoratorNode.getIndexWithinParent
Defined in
packages/lexical/src/LexicalNode.ts:386
getKey
▸ getKey(): string
Returns this nodes key.
Returns
string
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:378
getLatest
▸ getLatest(): this
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
Defined in
packages/lexical/src/LexicalNode.ts:744
getNextSibling
▸ getNextSibling<T
>(): null
| T
Returns the "next" siblings - that is, the node that comes after this one in the same parent
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Returns
null
| T
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:531
getNextSiblings
▸ getNextSiblings<T
>(): T
[]
Returns all "next" siblings - that is, the nodes that come between this one and the last child of it's parent, inclusive.
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Returns
T
[]
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:542
getNodesBetween
▸ getNodesBetween(targetNode
): LexicalNode
[]
Returns a list of nodes that are between this node and the target node in the EditorState.
Parameters
Name | Type | Description |
---|---|---|
targetNode | LexicalNode | the node that marks the other end of the range of nodes to be returned. |
Returns
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:663
getParent
▸ getParent<T
>(): null
| T
Returns the parent of this node, or null if none is found.
Type parameters
Name | Type |
---|---|
T | extends ElementNode |
Returns
null
| T
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:406
getParentKeys
▸ getParentKeys(): string
[]
Returns a list of the keys of every ancestor of this node, all the way up to the RootNode.
Returns
string
[]
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:483
getParentOrThrow
▸ getParentOrThrow<T
>(): T
Returns the parent of this node, or throws if none is found.
Type parameters
Name | Type |
---|---|
T | extends ElementNode |
Returns
T
Inherited from
DecoratorNode.getParentOrThrow
Defined in
packages/lexical/src/LexicalNode.ts:417
getParents
▸ getParents(): ElementNode
[]
Returns a list of the every ancestor of this node, all the way up to the RootNode.
Returns
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:468
getPreviousSibling
▸ getPreviousSibling<T
>(): null
| T
Returns the "previous" siblings - that is, the node that comes before this one in the same parent.
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Returns
null
| T
Inherited from
DecoratorNode.getPreviousSibling
Defined in
packages/lexical/src/LexicalNode.ts:498
getPreviousSiblings
▸ getPreviousSiblings<T
>(): T
[]
Returns the "previous" siblings - that is, the nodes that come between this one and the first child of it's parent, inclusive.
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Returns
T
[]
Inherited from
DecoratorNode.getPreviousSiblings
Defined in
packages/lexical/src/LexicalNode.ts:509
getTextContent
▸ getTextContent(): string
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
Defined in
packages/lexical/src/LexicalNode.ts:794
getTextContentSize
▸ getTextContentSize(): number
Returns the length of the string produced by calling getTextContent on this node.
Returns
number
Inherited from
DecoratorNode.getTextContentSize
Defined in
packages/lexical/src/LexicalNode.ts:802
getTopLevelElement
▸ getTopLevelElement(): null
| ElementNode
| DecoratorBlockNode
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
null
| ElementNode
| DecoratorBlockNode
Inherited from
DecoratorNode.getTopLevelElement
Defined in
packages/lexical/src/nodes/LexicalDecoratorNode.ts:20
getTopLevelElementOrThrow
▸ getTopLevelElementOrThrow(): ElementNode
| DecoratorBlockNode
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
| DecoratorBlockNode
Inherited from
DecoratorNode.getTopLevelElementOrThrow
Defined in
packages/lexical/src/nodes/LexicalDecoratorNode.ts:21
getType
▸ getType(): string
Returns the string type of this node.
Returns
string
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:291
getWritable
▸ getWritable(): this
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
Defined in
packages/lexical/src/LexicalNode.ts:761
insertAfter
▸ insertAfter(nodeToInsert
, restoreSelection?
): LexicalNode
Inserts a node after this LexicalNode (as the next sibling).
Parameters
Name | Type | Default value | Description |
---|---|---|---|
nodeToInsert | LexicalNode | undefined | 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
Defined in
packages/lexical/src/LexicalNode.ts:984
insertBefore
▸ insertBefore(nodeToInsert
, restoreSelection?
): LexicalNode
Inserts a node before this LexicalNode (as the previous sibling).
Parameters
Name | Type | Default value | Description |
---|---|---|---|
nodeToInsert | LexicalNode | undefined | 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
Defined in
packages/lexical/src/LexicalNode.ts:1051
is
▸ is(object
): boolean
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
Name | Type | Description |
---|---|---|
object | undefined | null | LexicalNode | the node to perform the equality comparison on. |
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:590
isAttached
▸ isAttached(): boolean
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 ultimatelt be cleaned up by the Lexical GC.
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:308
isBefore
▸ isBefore(targetNode
): boolean
Returns true if this node logical precedes the target node in the editor state.
Parameters
Name | Type | Description |
---|---|---|
targetNode | LexicalNode | the node we're testing to see if it's after this one. |
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:602
isDirty
▸ isDirty(): boolean
Returns true if this node has been marked dirty during this update cycle.
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:733
isInline
▸ isInline(): false
Returns
false
Overrides
Defined in
packages/lexical-react/src/LexicalDecoratorBlockNode.ts:59
isIsolated
▸ isIsolated(): boolean
Returns
boolean
Inherited from
Defined in
packages/lexical/src/nodes/LexicalDecoratorNode.ts:39
isKeyboardSelectable
▸ isKeyboardSelectable(): boolean
Returns
boolean
Inherited from
DecoratorNode.isKeyboardSelectable
Defined in
packages/lexical/src/nodes/LexicalDecoratorNode.ts:47
isParentOf
▸ isParentOf(targetNode
): boolean
Returns true if this node is the parent of the target node, false otherwise.
Parameters
Name | Type | Description |
---|---|---|
targetNode | LexicalNode | the would-be child node. |
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:641
isParentRequired
▸ isParentRequired(): boolean
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
DecoratorNode.isParentRequired
Defined in
packages/lexical/src/LexicalNode.ts:1091
isSelected
▸ isSelected(selection?
): boolean
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
Name | Type | Description |
---|---|---|
selection? | null | BaseSelection | The selection that we want to determine if the node is in. |
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:332