MessageDraft object
MessageDraft
is an object that refers to a single message that has not been published yet.
Properties
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.
addLinkedText()
addMentionedUser()
addReferencedChannel()
addQuote()
getHighlightedMention()
getMessagePreview()
onChange()
removeLinkedText()
removeMentionedUser()
removeReferencedChannel()
removeQuote()
send()
Use case
For example, you can use the MessageDraft
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 #
.