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
ErrorBanner
| Name | Default | Description |
|---|---|---|
children Required | React.ReactNodeThe error message to display |
MarkdownEditor
| Name | Default | Description |
|---|---|---|
ref | React.Ref<MarkdownEditorHandle> | |
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 | |
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 | |
referenceSuggestions | SuggestionOptions<Reference>Array of all possible references to suggest. Leave | |
onUploadFile | (file: File, onProgress?: (progressBytes: number) => void) => 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 | |
banner | React.ReactNodeOptional banner to display inside the editor, below the input area.
Typically used for error, info, or warning messages. Use Note: File upload errors (from drag-and-drop/paste) take priority over this banner and will be displayed instead when present. | |
teamHovercardsEnabled | booleanUse hovercards for team mentions in preview mode | |
className | stringOptional class name | |
generatingText | booleanWhen true, displays a skeleton loading state instead of the textarea. | |
hybridEditorProps | HybridEditorPropsProps that only apply to the new hybrid Markdown editing experience. Will be forwarded through to the
|
RenderEmoji
| Name | Default | Description |
|---|---|---|
emoji Required | Emoji | |
tone | number |