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

No props documented

ErrorBanner

NameDefaultDescription
children Required
React.ReactNode

The error message to display

MarkdownEditor

NameDefaultDescription
ref
React.Ref<MarkdownEditorHandle>
value Required
string

Current value of the editor as a multiline markdown string.

onChange Required
(newMarkdown: string) => void

Called when the value changes.

onInputFocus
() => void

Called 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
boolean

Disable the editor and all related buttons. Users can still switch between preview & edit modes.

placeholder
string

Placeholder text to show when the editor is empty. By default, no placeholder will be shown.

maxLength
number

Maximum number of characters the markdown can hold (includes formatting characters like *).

fullHeight
boolean

Force 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
string

ID of the describing element.

labelledBy
string

ID of the labelling element.

viewMode
MarkdownViewMode

Optionally control the view mode. If uncontrolled, leave this undefined.

onChangeViewMode
(newViewMode: MarkdownViewMode) => void

If viewMode is controlled, this will be called on change.

onPrimaryAction
() => void

Called when the user presses Ctrl/Cmd + Enter. Should almost always be wired to the same event as clicking the primary actionButton.

minHeightLines
5
number

Minimum number of visible lines of text in the editor.

maxHeightLines
35
number

Maximum number of visible lines of text in the editor. Has no effect if fullHeight = true.

emojiSuggestions
SuggestionOptions<Emoji>

Array of all possible emojis to suggest. Leave undefined to disable emoji autocomplete.

emojiTone
number

Skin 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 undefined to disable @-mention autocomplete.

referenceSuggestions
SuggestionOptions<Reference>

Array of all possible references to suggest. Leave undefined to disable #-reference autocomplete.

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 onUploadFile is defined but this array is not, all file types will be accepted. You can still reject file types by rejecting the onUploadFile promise, but setting this array provides a better user experience by preventing the upload in the first place.

onFilesRejected
(files: File[], rejectedTypes: string[]) => void

Callback when files are rejected due to unsupported file types. Useful for analytics tracking.

monospace
boolean

Control whether the editor font is monospace.

required
boolean

Control whether the input is required.

name
string

The name that will be given to the textarea.

savedReplies
SavedReply[]

To enable the saved replies feature, provide an array of replies.

onSavedRepliesOpen
() => void

Callback when the saved replies picker is opened

pasteUrlsAsPlainText
boolean

Control whether URLs are pasted as plain text instead of as formatted links (if the user has selected some text before pasting). Defaults to false (URLs will paste as links). This should typically be controlled by user settings.

Users can always toggle this behavior by holding shift when pasting.

banner
React.ReactNode

Optional banner to display inside the editor, below the input area. Typically used for error, info, or warning messages. Use MarkdownEditor.ErrorBanner for error messages to get consistent styling and accessibility.

Note: File upload errors (from drag-and-drop/paste) take priority over this banner and will be displayed instead when present.

teamHovercardsEnabled
boolean

Use hovercards for team mentions in preview mode

className
string

Optional class name

generatingText
boolean

When true, displays a skeleton loading state instead of the textarea.

hybridEditorProps
HybridEditorProps

Props that only apply to the new hybrid Markdown editing experience. Will be forwarded through to the HybridMarkdownEditor component and will not have any effect unless hybrid mode is selected.

RenderEmoji

NameDefaultDescription
emoji Required
Emoji
tone
number