For AI agents: Find a documentation index at https://talkjs.com/llms.txt (full content at https://talkjs.com/llms-full.txt). Get a markdown version of any page by appending .md to its URL path.

Message content

Structure text, attachments, and location shares in a message.

View as Markdown

Every message has "content" which specifies the information in the message. This could be some formatted text, a file attachment, or a shared location.

See the conceptual documentation for message content to learn more about how TalkJS represents message content.

protocol ContentBlock

The content of a message is structured as a list of content blocks.

No properties or methods are currently defined.

struct TextBlock

A block of formatted text in a message’s content.

Method Overview

constructor
==

Inherited from Equatable.==(_:_:).

Properties

children
: EntityTree

constructor

TextBlock(children:)

Parameters

children
: EntityTree

==

func textBlock.==(_:_:) -> Bool

Inherited from Equatable.==(_:_:).

Parameters

lhs (unnamed)
: TextBlock
rhs (unnamed)
: TextBlock

Returns

Bool
Full documentation of each TextNode variant

struct Markup

A node in a TextBlock that renders its children with a specific style.

Method Overview

constructor
==

Inherited from Equatable.==(_:_:).

Properties

children
: EntityTree
type
: String

The kind of formatting to apply when rendering the children

  • type: "bold" is used when users type *text* and is rendered with HTML <strong>
  • type: "italic" is used when users type _text_ and is rendered with HTML <em>
  • type: "strikethrough" is used when users type ~text~ and is rendered with HTML <s>

constructor

Markup(type:children:) throws

Parameters

type
: String
children
: EntityTree

==

func markup.==(_:_:) -> Bool

Inherited from Equatable.==(_:_:).

Parameters

lhs (unnamed)
: Markup
rhs (unnamed)
: Markup

Returns

Bool

struct BulletList

A node in a TextBlock that adds indentation for a bullet-point list around its children (HTML <ul>).

Method Overview

constructor
==

Inherited from Equatable.==(_:_:).

Properties

children
: EntityTree

constructor

BulletList(children:)

Parameters

children
: EntityTree

==

func bulletList.==(_:_:) -> Bool

Inherited from Equatable.==(_:_:).

Parameters

lhs (unnamed)
: BulletList
rhs (unnamed)
: BulletList

Returns

Bool

struct BulletPoint

A node in a TextBlock that renders its children with a bullet-point (HTML <li>).

Method Overview

constructor
==

Inherited from Equatable.==(_:_:).

Properties

children
: [EntityTreeNode]

constructor

BulletPoint(children:)

Parameters

children
: [EntityTreeNode]

==

func bulletPoint.==(_:_:) -> Bool

Inherited from Equatable.==(_:_:).

Parameters

lhs (unnamed)
: BulletPoint
rhs (unnamed)
: BulletPoint

Returns

Bool

A node in a TextBlock that renders its children as a clickable link (HTML <a>).

constructor
==

Inherited from Equatable.==(_:_:).

: EntityTree

Inherited from Clickable.children.

: String

The URL to open when the node is clicked.

Link(url:children:)

Parameters

: String
: EntityTree
func link.==(_:_:) -> Bool

Inherited from Equatable.==(_:_:).

Parameters

: Link
: Link

Returns

Bool

A node in a TextBlock that renders text as a link (HTML <a>).

: String

The text to display in the link.

: String

The URL to open when a user clicks this node.

AutoLink(url:text:)

Parameters

: String
: String

A node in a TextBlock that renders its children as a clickable action link which triggers a custom action.

constructor
==

Inherited from Equatable.==(_:_:).

: String

The name of the custom action to invoke when the link is clicked.

: EntityTree

Inherited from Clickable.children.

: CustomData

The parameters to pass to the custom action when the link is clicked.

ActionLink(action:params:children:)

Parameters

: String
: CustomData
: EntityTree
func actionLink.==(_:_:) -> Bool

Inherited from Equatable.==(_:_:).

Parameters

: ActionLink
: ActionLink

Returns

Bool

struct ActionButton

A node in a TextBlock that renders its children as a clickable action button which triggers a custom action.

Method Overview

constructor
==

Inherited from Equatable.==(_:_:).

Properties

action
: String

The name of the custom action to invoke when the button is clicked.

children
: EntityTree

Inherited from Clickable.children.

params
: CustomData

The parameters to pass to the custom action when the button is clicked.

constructor

ActionButton(action:params:children:)

Parameters

action
: String
params
: CustomData
children
: EntityTree

==

func actionButton.==(_:_:) -> Bool

Inherited from Equatable.==(_:_:).

Parameters

lhs (unnamed)
: ActionButton
rhs (unnamed)
: ActionButton

Returns

Bool

struct CodeSpan

A node in a TextBlock that renders text in an inline code span (HTML <code>).

Method Overview

Properties

text
: String

Inherited from Leaf.text.

constructor

CodeSpan(text:)

Parameters

text
: String

struct CustomEmoji

A node in a TextBlock that is used for custom emoji.

Method Overview

Properties

text
: String

The name (including colons at the start and end) of the custom emoji to show.

constructor

CustomEmoji(text:)

Parameters

text
: String

struct Mention

A node in a TextBlock that is used when a user is mentioned.

Method Overview

Properties

id
: String

The ID of the user who is mentioned.

text
: String

The name of the user who is mentioned.

constructor

Mention(id:text:)

Parameters

id
: String
text
: String

protocol FileBlock

No properties or methods are currently defined.

Full documentation of each FileBlock variant

struct GenericFileBlock

The most basic FileBlock variant, used whenever there is no additional metadata for a file.

Method Overview

Properties

filename
: String

The name of the file, including file extension

fileToken
: String

An encoded identifier for this file. Use in SendFileBlock to send this file in another message.

size
: Int64

The size of the file in bytes

url
: String

The URL where you can fetch the file

constructor

GenericFileBlock(url:size:filename:fileToken:)

Parameters

url
: String
size
: Int64
filename
: String
fileToken
: String

struct VideoBlock

A FileBlock variant for a video attachment, with additional video-specific metadata.

Method Overview

Properties

duration (optional)
: Double?

The duration of the video in seconds, if known.

filename
: String

The name of the video file, including file extension.

fileToken
: String

An encoded identifier for this file. Use in SendFileBlock to send this video in another message.

height (optional)
: Int?

The height of the video in pixels, if known.

size
: Int64

The size of the file in bytes.

url
: String

The URL where you can fetch the file.

width (optional)
: Int?

The width of the video in pixels, if known.

constructor

VideoBlock(url:size:filename:fileToken:width:height:duration:)

Parameters

url
: String
size
: Int64
filename
: String
fileToken
: String
width (optional)
: Int?
height (optional)
: Int?
duration (optional)
: Double?

struct ImageBlock

A FileBlock variant for an image attachment, with additional image-specific metadata.

Method Overview

Properties

filename
: String

The name of the image file, including file extension.

fileToken
: String

An encoded identifier for this file. Use in SendFileBlock to send this image in another message.

height (optional)
: Int?

The height of the image in pixels, if known.

size
: Int64

The size of the file in bytes.

url
: String

The URL where you can fetch the file.

width (optional)
: Int?

The width of the image in pixels, if known.

constructor

ImageBlock(url:size:filename:fileToken:width:height:)

Parameters

url
: String
size
: Int64
filename
: String
fileToken
: String
width (optional)
: Int?
height (optional)
: Int?

struct AudioBlock

A FileBlock variant for an audio attachment, with additional audio-specific metadata.

Method Overview

Properties

duration (optional)
: Double?

The duration of the audio in seconds, if known

filename
: String

The name of the audio file, including file extension

fileToken
: String

An encoded identifier for this file. Use in SendFileBlock to send this file in another message.

size
: Int64

The size of the file in bytes

url
: String

The URL where you can fetch the file

constructor

AudioBlock(url:size:filename:fileToken:duration:)

Parameters

url
: String
size
: Int64
filename
: String
fileToken
: String
duration (optional)
: Double?

struct VoiceBlock

A FileBlock variant for a voice recording attachment, with additional voice-recording-specific metadata.

Method Overview

Properties

duration (optional)
: Double?

The duration of the voice recording in seconds, if known

filename
: String

The name of the file, including file extension

fileToken
: String

An encoded identifier for this file. Use in SendFileBlock to send this voice recording in another message.

size
: Int64

The size of the file in bytes

url
: String

The URL where you can fetch the file

constructor

VoiceBlock(url:size:filename:fileToken:duration:)

Parameters

url
: String
size
: Int64
filename
: String
fileToken
: String
duration (optional)
: Double?

struct LocationBlock

A block showing a location in the world, typically because a user shared their location in the chat.

Method Overview

Properties

latitude
: Double

The north-south coordinate of the location.

Usually listed first in a pair of coordinates.

Must be a number between -90 and 90

longitude
: Double

The east-west coordinate of the location.

Usually listed second in a pair of coordinates.

Must be a number between -180 and 180

constructor

LocationBlock(latitude:longitude:)

Parameters

latitude
: Double
longitude
: Double

protocol SendContentBlock

The version of ContentBlock that is used when sending or editing messages.

No properties or methods are currently defined.

struct SendFileBlock

The version of FileBlock that is used when sending or editing messages.

Method Overview

Properties

fileToken
: String

The encoded identifier for the file, obtained by uploading a file with Session/sendFile, or taken from another message.

constructor

SendFileBlock(fileToken:)

Parameters

fileToken
: String