@lexical/hashtag
Classes
HashtagNode
Defined in: packages/lexical-hashtag/src/LexicalHashtagNode.ts:15
Extends
Methods
$config()
$config():
BaseStaticNodeConfig&object&object&StaticNodeTypeAccessor<"hashtag">
Defined in: packages/lexical-hashtag/src/LexicalHashtagNode.ts:16
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 & object & StaticNodeTypeAccessor<"hashtag">
Example
class MyNode extends TextNode {
$config() {
return this.config('my-node', {extends: TextNode});
}
}
Overrides
canInsertTextBefore()
canInsertTextBefore():
boolean
Defined in: packages/lexical-hashtag/src/LexicalHashtagNode.ts:26
This method is meant to be overridden 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
createDOM()
createDOM(
config):HTMLElement
Defined in: packages/lexical-hashtag/src/LexicalHashtagNode.ts:20
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
Overrides
isTextEntity()
isTextEntity():
true
Defined in: packages/lexical-hashtag/src/LexicalHashtagNode.ts:30
This method is meant to be overridden by TextNode subclasses to control the behavior of those nodes when used with the registerLexicalTextEntity function. If you're using registerLexicalTextEntity, the node class that you create and replace matched text with should return true from this method.
Returns
true
true if the node is to be treated as a "text entity", false otherwise.
Overrides
Interfaces
HashtagConfig
Defined in: packages/lexical-hashtag/src/LexicalHashtagExtension.ts:284
Properties
getHashtagMatch
getHashtagMatch: (
text) => {end:number;start:number; } |null
Defined in: packages/lexical-hashtag/src/LexicalHashtagExtension.ts:292
The matching function used by the extension. Has a default implementation that should be suitable for most use cases.
Parameters
text
string
The string of text to match
Returns
{ end: number; start: number; } | null
null if no match, otherwise an object with the start and end index of the first #hashtag match
Variables
HashtagExtension
constHashtagExtension:LexicalExtension<HashtagConfig,"@lexical/hashtag/Hashtag",unknown,unknown>
Defined in: packages/lexical-hashtag/src/LexicalHashtagExtension.ts:298
Add #hashtag support to the editor
Functions
$createHashtagNode()
$createHashtagNode(
text?):HashtagNode
Defined in: packages/lexical-hashtag/src/LexicalHashtagNode.ts:40
Generates a HashtagNode, which is a string following the format of a # followed by some text, eg. #lexical.
Parameters
text?
string = ''
The text used inside the HashtagNode.
Returns
- The HashtagNode with the embedded text.
$isHashtagNode()
$isHashtagNode(
node):node is HashtagNode
Defined in: packages/lexical-hashtag/src/LexicalHashtagNode.ts:49
Determines if node is a HashtagNode.
Parameters
node
LexicalNode | null | undefined
The node to be checked.
Returns
node is HashtagNode
true if node is a HashtagNode, false otherwise.