[Feature] File preview #10455

Closed
opened 2025-11-02 09:07:53 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @TimerWolf on GitHub (Mar 19, 2023).

Feature Description

When you use the web interface, why is it not possible to have preview of a new file that is created in the repository?

You can do it with already created files that you edit but not with new files and i find this very strange, it would be very useful for lets say is you create a new "markdown" file.

Repository -> Add File -> New File

But the preview tab is missing

Originally created by @TimerWolf on GitHub (Mar 19, 2023). ### Feature Description When you use the web interface, why is it not possible to have preview of a new file that is created in the repository? You can do it with already created files that you edit but not with new files and i find this very strange, it would be very useful for lets say is you create a new "markdown" file. `Repository -> Add File -> New File` But the preview tab is missing
GiteaMirror added the type/proposaltype/feature labels 2025-11-02 09:07:53 -06:00
Author
Owner

@silverwind commented on GitHub (Mar 19, 2023):

Preview Tab should be there for at least markdown, but I do agree we could show it for other file types as well, if there is a benefit.

Also see https://github.com/go-gitea/gitea/pull/23333 which touches these parts.

@silverwind commented on GitHub (Mar 19, 2023): Preview Tab should be there for at least markdown, but I do agree we could show it for other file types as well, if there is a benefit. Also see https://github.com/go-gitea/gitea/pull/23333 which touches these parts.
Author
Owner

@brechtvl commented on GitHub (Mar 19, 2023):

The Preview tab is not there for New File at all, only for Edit File. Editing a .txt file and renaming it to .md also does not make a Preview tab appear.

I had a quick look, and there seem to be two things to fix:

  • Make the preview tab visible for IsNewFile in templates/repo/editor/edit.tmpl
  • Run the previewable file extensions detection in createCodeEditor after editing the file name, not only on page load.

I won't have time to submit a proper fix in the next few days, anyone feel free to take over. Otherwise I'll get to it later.

@brechtvl commented on GitHub (Mar 19, 2023): The Preview tab is not there for New File at all, only for Edit File. Editing a `.txt` file and renaming it to `.md` also does not make a Preview tab appear. I had a quick look, and there seem to be two things to fix: * Make the preview tab visible for `IsNewFile` in `templates/repo/editor/edit.tmpl` * Run the previewable file extensions detection in `createCodeEditor` after editing the file name, not only on page load. I won't have time to submit a proper fix in the next few days, anyone feel free to take over. Otherwise I'll get to it later.
Author
Owner

@silverwind commented on GitHub (Mar 20, 2023):

I agree, we should try to handle new file similar to edit file.

@silverwind commented on GitHub (Mar 20, 2023): I agree, we should try to handle new file similar to edit file.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10455