MessageDraftV2 object
MessageDraftV2
is an object that refers to a single message that has not been published yet.
Message draft versions
The message draft feature comes in two versions. Although version 1 is not deprecated, we recommend that you use version 2.
Version 2 lets you work with user mentions, channel references, and links (collectively called "message elements") in a more generic manner than version 1. For more information on message drafts, refer to Drafts (v2) and Drafts (v1).
- Version 2
- Version 1
The MessageDraftV2
object has the following properties:
class MessageDraftV2 {
channel: Channel,
value: string,
quotedMessage?: Message,
config: MessageDraftConfig,
files?: FileList | File[] | SendFileParameters["file"][];
}
Parameter | Type | Description |
---|---|---|
channel | Channel | The channel the draft message is being created on. |
value | string | Message that includes mentions. |
quotedMessage | Message or undefined | Object added to a draft message when you quote another message. |
config | MessageDraftConfig | Configuration of the message containing mentions - what is the user source (channel members or app's keyset users), whether the typing indicator is enabled, and what is the maximum number of user names mentioned in one message (the default value is 10 and max is 100 ). |
files | FileList or File[] or SendFileParameters["file"][] , or undefined | One or multiple files attached to the draft text message. They can take the form of a read-only files property of the HTML <input /> element (when a user has selected one or more files from their device), or through a drag-and-drop operation (FileList ). Alternatively, that can be an array of file objects (File[] ) or PubNub-specific `SendFileParameters["file"][]. |
Methods
You can call the following methods on the MessageDraft
object.
Click on each method for more details.
The MessageDraft
object has the following properties:
class MessageDraft {
value: string,
quotedMessage?: Message,
config: MessageDraftConfig,
files?: FileList | File[] | FileInput[]
}
Parameter | Type | Description |
---|---|---|
value | string | Message that includes mentions. |
quotedMessage | Message or undefined | Object added to a draft message when you quote another message. |
config | MessageDraftConfig | Configuration of the message containing mentions - what is the user source (channel members or app's keyset users), whether the typing indicator is enabled, and what is the maximum number of user names mentioned in one message (the default value is 10 and max is 100 ). |
files | FileList , File[] , FileInput[] , or undefined | One or multiple files attached to the draft text message. They can take the form of a read-only files property of the HTML <input /> element (when a user has selected one or more files from their device), or through a drag-and-drop operation (FileList ). Alternatively, that can be an array of file objects (File[] ) or PubNub-specific FileInput (FileInput[] ). |
Methods
You can call the following methods on the MessageDraft
object.
Click on each method for more details.
Use case
For example, you can use the MessageDraftV2
object methods to let users work on the created draft messages to prepare the final content. They can enrich that content with links, mention other channel members with @
, or reference channels with #
.