Class: TabNode
lexical.TabNode
Hierarchy
-
↳
TabNode
Constructors
constructor
• new TabNode(key?
): TabNode
Parameters
Name | Type |
---|---|
key? | string |
Returns
Overrides
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:42
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;
}
}
Overrides
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:36
canInsertTextAfter
▸ canInsertTextAfter(): boolean
This method is meant to be overriden by TextNode subclasses to control the behavior of those nodes when a user event would cause text to be inserted after them in the editor. If true, Lexical will attempt to insert text into this node. If false, it will insert the text in a new sibling node.
Returns
boolean
true if text can be inserted after the node, false otherwise.
Overrides
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:88
canInsertTextBefore
▸ canInsertTextBefore(): boolean
This method is meant to be overriden by TextNode subclasses to control the behavior of those nodes when a user event would cause text to be inserted before them in the editor. If true, Lexical will attempt to insert text into this node. If false, it will insert the text in a new sibling node.
Returns
boolean
true if text can be inserted before the node, false otherwise.
Overrides
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:84
createDOM
▸ createDOM(config
): 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.
Parameters
Name | Type | Description |
---|---|---|
config | EditorConfig | allows access to things like the EditorTheme (to apply classes) during reconciliation. |
Returns
HTMLElement
Overrides
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:51
exportJSON
▸ exportJSON(): SerializedTextNode
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/src/nodes/LexicalTabNode.ts:64
setDetail
▸ setDetail(_detail
): this
Sets the node detail to the provided TextDetailType or 32-bit integer. Note that the TextDetailType version of the argument can only specify one detail value and doing so will remove all other detail values that may be applied to the node. For toggling behavior, consider using TextNode.toggleDirectionless or TextNode.toggleUnmergeable
Parameters
Name | Type | Description |
---|---|---|
_detail | number | TextDetailType | TextDetailType or 32-bit integer representing the node detail. |
Returns
this
this TextNode.
// TODO 0.12 This should just be a string
.
Overrides
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:76
setMode
▸ setMode(_type
): this
Sets the mode of the node.
Parameters
Name | Type |
---|---|
_type | TextModeType |
Returns
this
this TextNode.
Overrides
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:80
setTextContent
▸ setTextContent(_text
): this
Sets the text content of the node.
Parameters
Name | Type | Description |
---|---|---|
_text | string | the string to set as the text value of the node. |
Returns
this
this TextNode.
Overrides
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:72
clone
▸ clone(node
): TabNode
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
Name | Type |
---|---|
node | TabNode |
Returns
Overrides
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:32
getType
▸ getType(): string
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
Overrides
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:28
importDOM
▸ importDOM(): null
| DOMConversionMap
Returns
null
| DOMConversionMap
Overrides
Defined in
packages/lexical/src/nodes/LexicalTabNode.ts:47
importJSON
▸ importJSON(serializedTabNode
): TabNode
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
Name | Type |
---|---|
serializedTabNode | SerializedTextNode |