Repository navigation
web: migrate the repository file editor pages to React - #8532
Merged
Merged
Conversation
This was referenced Nov 13, 2026
unknwon
force-pushed
the
editor-react-flamego
branch
2 times, most recently
from
November 14, 2026 05:43
284a228 to
a55b369
Compare
unknwon
force-pushed
the
editor-react-flamego
branch
2 times, most recently
from
November 14, 2026 07:11
60b1992 to
e546371
Compare
unknwon
force-pushed
the
editor-react-flamego
branch
4 times, most recently
from
November 14, 2026 17:11
90887b8 to
febb16a
Compare
unknwon
force-pushed
the
editor-react-flamego
branch
2 times, most recently
from
November 14, 2026 19:00
a6c746c to
2eaadf9
Compare
unknwon
force-pushed
the
editor-react-flamego
branch
2 times, most recently
from
November 14, 2026 19:34
5308567 to
ed2ef35
Compare
unknwon
force-pushed
the
editor-react-flamego
branch
7 times, most recently
from
November 14, 2026 23:00
bb15e15 to
a5dda87
Compare
unknwon
force-pushed
the
editor-react-flamego
branch
4 times, most recently
from
November 15, 2026 02:17
0b552d0 to
a1238dd
Compare
unknwon
force-pushed
the
editor-react-flamego
branch
7 times, most recently
from
November 15, 2026 05:34
5bb293c to
97e6d6b
Compare
unknwon
force-pushed
the
editor-react-flamego
branch
6 times, most recently
from
November 16, 2026 00:46
afc10ce to
e19c1f5
Compare
unknwon
force-pushed
the
editor-react-flamego
branch
from
November 16, 2026 01:34
e19c1f5 to
285c2eb
Compare
unknwon
marked this pull request as ready for review
November 16, 2026 01:34
Editing, creating, deleting and uploading files of a branch are now React
pages backed by /api/web/{owner}/{repo}/editor. Code and Markdown are edited
in CodeEditor, which now follows the file name as it changes, and the changes
are previewed as a diff in the browser.
SimpleMDE and CodeMirror 5 are gone, along with the server-rendered editor,
its diff preview endpoint and the scripts that drove them.
The editor asks the branch's .editorconfig how to indent the file being edited, and follows it as the file name changes: tabs or spaces, the indent size and the tab width.
…tation - A new branch named after the branch being edited is refused as an existing branch instead of committing to it. - Deleting a file lands on the closest directory that is left, since directories that only held the file go away with it. - Typing a closing brace moves the line back to its indentation. - Cancel is an outline button, and uploading to the root defaults the summary to "Upload files to '/'".
unknwon
force-pushed
the
editor-react-flamego
branch
from
November 16, 2026 02:39
4f5b1e5 to
982019f
Compare
The editor's Preview tab rendered a Markdown file like an issue, which keeps line breaks since #8607, with links resolved against the repository root. It now renders like the file does, with links and images resolved against its directory, as the legacy editor did.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the pull request
Migrates the repository file editor to React: editing a file (
/{owner}/{repo}/_edit/{branch}/{path}), creating one (/_new/{branch}/{dir}), deleting one (/_delete/{branch}/{path}) and uploading files (/_upload/{branch}/{dir}). They are backed by/api/web/{owner}/{repo}/editor. SimpleMDE and CodeMirror 5 are removed from Gogs, soCodeEditor(CodeMirror 6) is the only editor left./adds a directory and Backspace at the start removes it), then the editor. The language follows the file name as you type it, e.g., renaming tomain.goswitches to Go with line numbers. Markdown files get a Preview tab. Edits get a Preview changes tab, a diff rendered in the browser with@pierre/diffs, like the commit page..editorconfigof the branch being edited: tabs or spaces, the indent size and the tab width, for the file name as it is typed.GET /editor-indent?branch=&path=answers it. Without rules, Tab indents by two spaces. Typing a closing brace moves the line back to its indentation.GET /editor/{branch}/{path}describes the branch and the path, thenPOST /editor/files,/editor/delete,/editor/upload, andPOST/DELETE /editor/uploads. The JSON routes take 10 MiB at most, and uploads keep[repository.upload] FILE_MAX_SIZE.internal/route/repo/editor.go, therepo/editor/*templates, the_preview,upload-fileandupload-removeroutes,database.GetDiffPreview,git.DiffCached, the editor form structs,RequireSimpleMDE,public/plugins/simplemde-1.10.1,public/plugins/codemirror-5.17.0, and about 360 lines of editor scripts ingogs.js.editor.commit_summary,commit_description,new_branch_name,invalid_branch_name,file_path,directory,delete_fileandno_files_to_upload.Behavior changes from legacy
.editorconfigis read from the branch being edited rather than the default branch, and matched against the whole path, so sections like[docs/**.md]apply.git check-ref-formatinstead of the alphanumeric, dash, dot and slash rule.a#b.goopens.Screenshots
Editing a Markdown file
Preview changes
Markdown preview
Preview changes, dark
The file changed while editing
New Go file in new directories, indented with tabs by
.editorconfig, to a new branchNew branch name already taken, here the branch being edited
Deleting a file
Uploading files
Checklist
Test plan
go test ./cmd/gogs/internal/web/ ./internal/route/... ./internal/database/ ./internal/git/passes, andTestRequireSignIncovers the new endpoint.moon run gogs:lintandmoon run web:lintreport 0 issues.-tags prodbuild with SQLite. Seed: alice owns the publicwidgets, the emptyemptyand the privatesecret. bob can write tosecretonly, and carol has no access.widgets, carol fromsecret, and alice fromempty. Signed-out visitors get 401 from the endpoints, and all four pages redirect to sign in. A missing branch andfeature/login, which only takes pull requests, get 404. A symlink cannot be edited, deleted or used as a directory.git login the bare repository: editedREADME.md, renamedetc/xtoetc/y.txt, createddocs/cmd/server/main.goin new directories, deleteddocs/a#b.go, and uploaded two files to the newdocs/drafts. The summary and description became the commit message, and an empty summary used the default. A new branchalice-patch-2led to/compare/master...alice:alice-patch-2. An existing branch name, a path that is a directory, renaming ontoREADME.mdand../../etc/xwere refused or cleaned with field messages. A file over 3 MB gets 413..editorconfigonmaster,main.gogets tabs 8 wide,ci.ymltwo spaces,docs/a.mdthree, and other files four. A branch without one gets no rules. Missing and pull-request-only branches get 404, bob gets 404 and signed-out visitors 401. In the browser, Tab inmain.goinserts a tab, and renaming the file toci.ymland thennotes.txtswitches Tab to two and four spaces./and Backspace, Go highlighting after typing the name, the new branch error, and removing an upload. No sideways scroll at 375.alice/alphawith an.editorconfig(tabs for*.go, two spaces for YAML, four otherwise):docs/guide.md, checked Preview (heading, list, tip alert, table) and Preview changes in light and dark, then bob changed the file behind the editor. Committing showed the conflict notice, and committing again overwrote it.cmd/worker/run.gointo the path field, which becamealpha / cmd / worker / run.go. In the editor, Enter after{indented with a tab and}moved back. Naming the new branchmainshowed "Branch 'main' already exists in this repository."alice-worker-runled to/compare/main...alice:alice-worker-run, andgit showhas the file with tabs.deep/a/b/only.golanded on/src/main/deep,sib/one.txt(with a sibling) on/src/main/sib, and a file whose directory only held it on the root. The delete button is solid red.docs/drafts, removed one copy of a duplicate, and found both files committed and no uploads left in the database. Uploading to the root committed "Upload files to '/'"._edit,_new,_uploadand the delete endpoint of alice's repository, and signed-out visitors are sent to sign in. Nothing scrolls sideways at 375.