Skip to content

added github flavoured markdown preview for issues and pull requests#8731

Open
Nareshix wants to merge 2 commits intomicrosoft:mainfrom
Nareshix:markdown-preview
Open

added github flavoured markdown preview for issues and pull requests#8731
Nareshix wants to merge 2 commits intomicrosoft:mainfrom
Nareshix:markdown-preview

Conversation

@Nareshix
Copy link
Copy Markdown

@Nareshix Nareshix commented May 7, 2026

Hi, I added this feature which closes #5382

Before creating a pull request, if the issues involves making changes to the UI, please discuss it in the issue beforehand. This will help keep reviews focused on the code changes.

This feature makes changes to the ui as shown below. I'm open to the discussion on how the ui should be displayed

Some images on how it looks like

  1. image
  2. image
  3. image
  4. image

Copilot AI review requested due to automatic review settings May 7, 2026 15:19
@Nareshix
Copy link
Copy Markdown
Author

Nareshix commented May 7, 2026

@microsoft-github-policy-service agree

@Nareshix
Copy link
Copy Markdown
Author

Nareshix commented May 7, 2026

One thing that i suggest is that we place the upload file icon below the textarea so that it can prevent the icon mixing with the text as shown below
image

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a GitHub-flavored Markdown “Write/Preview” experience to the extension’s webview editors (PR creation description and PR/issue comment boxes) by introducing a shared MarkdownEditor component and a new pr.render-markdown webview message that renders Markdown via GitHub’s Markdown API.

Changes:

  • Introduces a reusable MarkdownEditor webview component with Write/Preview tabs.
  • Adds a pr.render-markdown webview message flow and a GitHubRepository.renderMarkdown() helper that calls GitHub’s Markdown render API (GFM + repo context).
  • Replaces existing <textarea> usages for PR description and comment inputs with MarkdownEditor, plus styling in common CSS.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
webviews/createPullRequestViewNew/app.tsx Swaps PR description textarea for MarkdownEditor and wires renderMarkdown.
webviews/components/markdownEditor.tsx New Write/Preview editor component that renders returned HTML.
webviews/components/comment.tsx Replaces comment textareas with MarkdownEditor and passes renderMarkdown from context.
webviews/common/createContextNew.ts Adds renderMarkdown() that posts pr.render-markdown to the host.
webviews/common/context.tsx Adds renderMarkdown() for the PR/issue overview webview context.
webviews/common/common.css Adds styling for the new markdown editor and preview container.
src/github/issueOverview.ts Handles pr.render-markdown messages for issue/PR overview panels.
src/github/githubRepository.ts Adds renderMarkdown() that calls GitHub’s Markdown API.
src/github/createPRViewProvider.ts Handles pr.render-markdown messages in the Create PR webview.
src/github/activityBarViewProvider.ts Handles pr.render-markdown messages in the Active PR view.

Comment on lines +21 to +32
const setRefs = useCallback(
(node: HTMLTextAreaElement) => {
(internalRef as React.MutableRefObject<HTMLTextAreaElement | null>).current =
node;
if (typeof forwardedRef === 'function') {
forwardedRef(node);
} else if (forwardedRef) {
(
forwardedRef as React.MutableRefObject<HTMLTextAreaElement | null>
).current = node;
}
},
Comment thread webviews/components/markdownEditor.tsx
Comment on lines +99 to +103
{mode === 'preview' && (
<div className='markdown-editor-preview comment-body'>
{!isLoading && html && <div dangerouslySetInnerHTML={{ __html: html }} />}
{!isLoading && !html && <em>Nothing to preview</em>}
{isLoading && <em>Loading preview...</em>}
Comment thread src/github/githubRepository.ts
Comment thread src/github/githubRepository.ts
Comment thread src/github/issueOverview.ts Outdated
Comment thread src/github/createPRViewProvider.ts
Comment thread src/github/activityBarViewProvider.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown preview support

2 participants