MarkdownEditor
Textarea for editing Markdown.
Internal Component
This component is intended solely for use within GitHub and is not available for external use.Props
MarkdownEditor
MarkdownEditor
| Name | Default | Description |
|---|---|---|
value Required | stringCurrent value of the editor as a multiline markdown string. | |
onChange Required | (newMarkdown: string) => voidCalled when the value changes. | |
onInputFocus | () => voidCalled when the textarea gains focus. | |
onRenderPreview Required | (markdown: string) => Promise<SafeHTMLString>Accepts Markdown and returns rendered HTML. To prevent XSS attacks, the HTML should be sanitized and/or come from a trusted source. | |
children Required | React.ReactNode | |
disabled | booleanDisable the editor and all related buttons. Users can still switch between preview & edit modes. | |
placeholder | stringPlaceholder text to show when the editor is empty. By default, no placeholder will be shown. | |
maxLength | numberMaximum number of characters the markdown can hold (includes formatting characters like | |
fullHeight | booleanForce the editor to take up the full height of the container and disallow resizing. Only use when the container height is tall enough that the user will never want to expand the input further, ie when it takes the full height of the viewport. | |
aria-describedby | stringID of the describing element. | |
labelledBy | stringID of the labelling element. | |
viewMode | MarkdownViewModeOptionally control the view mode. If uncontrolled, leave this | |
onChangeViewMode | (newViewMode: MarkdownViewMode) => voidIf | |
onPrimaryAction | () => voidCalled when the user presses | |
minHeightLines | 5 | numberMinimum number of visible lines of text in the editor. |
maxHeightLines | 35 | numberMaximum number of visible lines of text in the editor. Has no effect if |
emojiSuggestions | SuggestionOptions<Emoji>Array of all possible emojis to suggest. Leave | |
onShowEmojiSuggestions | () => voidCallback for lazy-loading emoji suggestions. Called every time the emoji menu is requested. | |
emojiTone | numberSkin tone preference used for rendering applicable emoji suggestions between 1-5. 0 can be used as a default value. See: https://github.com/github/g-emoji-element?tab=readme-ov-file#skin-tones for more information. | |
mentionSuggestions | SuggestionOptions<Mentionable>Array of all possible mention suggestions. Leave | |
onShowMentionSuggestions | () => voidCallback for lazy-loading mention suggestions. Called every time the mention menu is requested. | |
referenceSuggestions | SuggestionOptions<Reference>Array of all possible references to suggest. Leave | |
onShowReferenceSuggestions | () => voidCallback for lazy-loading reference suggestions. Called every time the reference menu is requested. | |
onUploadFile | (file: File) => Promise<FileUploadResult>Uploads a file to a hosting service and returns the URL. If not provided, file uploads will be disabled. | |
acceptedFileTypes | FileType[]Array of allowed file types. If | |
onFilesRejected | (files: File[], rejectedTypes: string[]) => voidCallback when files are rejected due to unsupported file types. Useful for analytics tracking. | |
monospace | booleanControl whether the editor font is monospace. | |
required | booleanControl whether the input is required. | |
name | stringThe name that will be given to the | |
savedReplies | SavedReply[]To enable the saved replies feature, provide an array of replies. | |
onSavedRepliesOpen | () => voidCallback when the saved replies picker is opened | |
pasteUrlsAsPlainText | booleanControl whether URLs are pasted as plain text instead of as formatted links (if the
user has selected some text before pasting). Defaults to Users can always toggle this behavior by holding | |
errorMessage | stringOptional error message related to the markdown editor content. Displayed directly below editor. Useful for showing validation or other errors related directly to the markdown provided by the user. Note: This is separate from the error message related to drag-and-drop errors. | |
teamHovercardsEnabled | booleanUse hovercards for team mentions in preview mode | |
className | stringOptional class name |