Constructor
new RichText(text, offset, options)
Create a new RichText instance.
Parameters:
Name | Type | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
text |
String | The text to be annotated |
|||||||||||||||||||||||||||||||||||||||||||||
offset |
number | 0 | The offset of this particular piece of text from the start of the original message text. This is necessary because RichText instances can be nested when templates call directives which create new RichText instances (as happens with XEP-393 styling directives). |
||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
Properties
|
- Source:
Classes
Methods
addAnnotations(func)
Look for plaintext (i.e. non-templated) sections of this RichText instance and add references via the passed in function.
Parameters:
Name | Type | Description |
---|---|---|
func |
function |
- Source:
addEmojis(text, offset)
Look for emojis (shortnames or unicode) and add templates for rendering them.
Parameters:
Name | Type | Description |
---|---|---|
text |
String | |
offset |
number | The index of the passed in text relative to the start of the message body text. |
- Source:
addHyperlinks(text, local_offset)
Look for http
URIs and return templates that render them as URL links
Parameters:
Name | Type | Description |
---|---|---|
text |
String | |
local_offset |
number | The index of the passed in text relative to the start of this RichText instance (which is not necessarily the same as the offset from the start of the original message stanza's body text). |
- Source:
addMapURLs(text, offset)
Look for geo
URIs and return templates that render them as URL links
Parameters:
Name | Type | Description |
---|---|---|
text |
String | |
offset |
number | The index of the passed in text relative to the start of the message body text. |
- Source:
addMentions(text, local_offset)
Look for mentions included as XEP-0372 references and add templates for rendering them.
Parameters:
Name | Type | Description |
---|---|---|
text |
String | |
local_offset |
number | The index of the passed in text relative to the start of this RichText instance (which is not necessarily the same as the offset from the start of the original message stanza's body text). |
- Source:
addStyling()
Look for XEP-0393 styling directives and add templates for rendering them.
- Source:
(async) addTemplates()
Parse the text and add template references for rendering the "rich" parts.
- Source:
marshall()
Take the annotations and return an array of text and TemplateResult instances to be rendered to the DOM.
- Source:
(static) addTemplateResult(begin, end, template)
The "rich" markup parts of a chat message are represented by lit TemplateResult objects.
This method can be used to add new template results to this message's text.
Parameters:
Name | Type | Description |
---|---|---|
begin |
Number | The starting index of the plain message text which is being replaced with markup. |
end |
Number | The ending index of the plain message text which is being replaced with markup. |
template |
Object | The lit TemplateResult instance |
- Source: