Preview
Base Style
The editor itself is without any styling and the intention is to wrap it with another component, such as Message Input, that provides the UI.
With Links
Output Format
There are 3 defined output formats currently for the input text.
Text
Provide prop outputFormat: 'text'
Plain text format as output without taking into consideration any marks (italics, bold) / html tags/ codeblocks that may be included in the input text user provides.
Json
Provide prop outputFormat: 'json'
the input will be formatted as a json document that can then be consumed by product.
The type of the each node in the input will be present for example: codeblock, image
along with other meta data pertaining to the text node.
HTML
Provide prop outputFormat: 'html'
the input will be formatted as native html that can then be consumed by product.
Tiptap Plugins Used
HardBreak
HardBreak plugin is used to add support for <br> tags in the rich text editor.
CodeBlocks
Codeblock plugin is used to enable the support for code and also specify the language. Type ``` followed by space or ~~~ with space to enable a codeblock in the rich text editor.
Placeholder
Provides support to enable placeholder support
Mention
The tiptap Mention plugin is apt for our use case of mentioning users or channels within the editor. It also creates the respective nodes with ability for user to customize the trigger character.
How to Use the Mention Plugin:
When using the Rich Text editor, the developer would have to pass in the suggestion object prop which MUST contain an items function that takes in a query and returns a list of object with the properties:
{
id: String,
name: String,
avatarSrc: String
}
There can be additional properties that override the mention plugin and more details can be seen here: Suggestion Tiptap utility. If this mentionSuggestion Object prop is not supplied, the mention plugin is disabled by default.
To see it in action type char '@' into rich editor With channel mentions.
Vue API
import { DtRichTextEditor } from '@dialpad/dialtone-vue';