Preview new files before committing them

What does this MR do and why?

Implements Add preview for new markup files (#15501), a decade-old feature request.

Add the same Write and Preview tabs the edit page has to the new file page.

The edit page's preview machinery carries over as is: the renderer is picked from the file name in the editor (Follow mid-edit renames in the preview renderer (!251790 - merged)), and the live preview follows the Markdown extensions currently loaded (Follow mid-edit renames to Markdown in the "Pre... (!250889 - merged)), so the frontend (edit_blob.js) needs no changes.

That leaves the view and the controller: add the tabs to the view, and make the preview action, which assumed a committed blob, work without one (new files, empty repositories).

Build on

Screen recordings

Manually verified in GDK-in-a-box:

How to set up and validate locally

  1. Open a directory in a repository and select + > New file, then enter * Now you see me as the content
  2. Name the file README.md and click Preview — the Markdown live preview opens
  3. Rename it to README.org and click Preview — the content renders as an Org-mode heading
  4. Rename it to README.txt and click Preview — a diff with every line added

Notes

  • Backend engineer, but fairly new to Rails. Feedback on Rails conventions welcome.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by skkzsh

Merge request reports

Loading
Loading