Rich Text Editor

Alignment target:@astryxdesign/richtext v0.7.1 · RichTextEditor

<RichTextEditor> props #

PropTypeDefaultDescription
labelstringRequiredEditor label text for accessibility and screen readers.
isLabelHiddenbooleanfalseVisually hides the label while keeping it accessible to screen readers.
descriptionstring-Helper text displayed between the label and the editing area.
isOptionalbooleanfalseMarks the field as optional (mutually exclusive with isRequired).
isRequiredbooleanfalseMarks the field as required (mutually exclusive with isOptional).
defaultValuestring-Initial content JSON string, read only once on mount.
placeholderstring-Placeholder text shown when content is empty.
isReadOnlybooleanfalseWhether the editor is read-only. Non-editable, text stays clear, and still focusable via Tab.
isDisabledbooleanfalseWhether the editor is disabled. Non-editable, colors fade, and removed from Tab order. Takes precedence when both isReadOnly and isDisabled are true.
statusRichTextEditorStatus-Validation status { type, message? }. Sets border color and displays a message below.
statusVariant'attached' | 'detached' | 'tooltip''attached'Display placement of the status message.
widthnumber | string-Field width. Numbers are in pixels; strings are CSS lengths.
minHeightnumber | string'4.5rem'Minimum height of the editing area. Expands automatically with content.
labelTooltipstring-Tooltip text for the info icon next to the label.
size'sm' | 'md' | 'lg''md'Editor size, affecting internal padding.
nodesReadonlyArray<Klass<LexicalNode>>-Additional Lexical node types to register.
extensionsReadonlyArray<AnyLexicalExtensionArgument>-Additional Lexical extension plugin array.
markdownExtensionsReadonlyArray<RichTextMarkdownExtension>-Markdown extension plugins to recognize.
hasMarkdownShortcutsbooleantrueWhether to enable Markdown shortcuts (such as # for headings).
transformersReadonlyArray<Transformer>Default transformersCustom Markdown transformation rules.
hasAutoFocusbooleanfalseWhether to automatically focus the editing area on mount.
tabEscapeHintstringLocalized textScreen reader hint to press Escape then Tab to leave; pass "" to hide.
maxLengthnumber-Character limit for plain text. Exceeding it shows an error style on the counter.
namespacestring'astryx-editor'Namespace for the underlying Lexical instance.
  • Events: @change="(editorState, editor) => void" fires when content changes, used for saving state.
  • Slots: #toolbar top toolbar slot; #default internal plugin slot (such as placing <RichTextEditorAutoLinkPlugin>).
  • Template ref methods: focus() focuses; clear() clears; getEditorState() gets state; getMarkdown() exports Markdown; getHTML() exports HTML; getEditor() gets underlying Lexical instance.

<RichTextEditorToolbar> props and slots #

PropTypeDefaultDescription
labelstringLocalized textAccessible name for the toolbar.
headingLevelsReadonlyArray<'h1' | 'h2' | 'h3'>['h1', 'h2', 'h3']Heading levels included in the block format dropdown.
size'sm' | 'md' | 'lg''sm'Toolbar size.
hasLinkbooleantrueWhether to show the link button and enable Cmd/Ctrl+K shortcut.
promptForUrl(selectedText: string) => string | null | undefined-Custom callback function to prompt for a URL.
hasNewTabLinksbooleantrueWhether inserted links open in a new tab.
  • Slots: #end custom slot at the end, rendered to the right of default buttons.

<RichTextView> props, events and slots #

PropTypeDefaultDescription
valuestringRequiredEditor state JSON string to render.
nodesReadonlyArray<Klass<LexicalNode>>-Additional Lexical nodes to register, matching those used when saving.
markdownExtensionsReadonlyArray<RichTextMarkdownExtension>-Markdown extension plugins to recognize.
namespacestring'astryx-view'Namespace for the underlying Lexical instance.
  • Events: @parseError="(error: Error) => void" fires when parsing content fails.
  • Slots: #errorFallback fallback content when parsing fails; #default internal extension slot.