2.4
Rich text editor
Used to content editor based Tiptap.js
Import
import { MpRichTextEditor, MpRTEStyleProvider } from '@mekari/pixel3'Playground
API
MpRichTextEditor
| Name | Type | Default |
|---|---|---|
id | string | - |
value | string | - |
placeholder | string | - |
maxlength | number | - |
options | heading | bold | italic | underline | strike | blockquote
| bulletList | orderedList | align | mention | variable | textLink
| image | file | audio | location | undo | redo | clear
| { value: string, tooltip?: string } | - |
suggestions | array | [] |
variables | VariableSuggestionItem[] | [] |
is-disabled | boolean | false |
is-invalid | boolean | false |
has-border | boolean | false |
validate-link | (url: string, ctx: { defaultValidate: (url: string) => boolean; protocols: string[] }) => boolean | - |
transform-link | (url: string) => string | - |
MpRTEStyleProvider
| Name | Type | Default |
|---|---|---|
id | string | - |
Usage
Advance usage
Use emit action or paste event to handle attach image, file, audio
Link validation and transformation
Use validate-link prop to customize link validation rules and transform-link to auto-transform URLs (e.g. adding https:// to "example.com"). The input field will show an invalid state when the URL doesn't pass validation, and the accept button will be disabled.
Transformation happens before validation, allowing you to normalize URLs before they're checked.
Variable insertion
Use the variables prop to enable dynamic variable placeholders in your content. Users can type { to trigger the variable dropdown, which displays categorized variables that can be inserted with a click or keyboard selection.
Variables are inserted as special nodes with data attributes, making them easy to identify and replace with actual values during processing.
Attachment limit
Use disabled on toolbar option to disable attachment buttons when a limit is reached.