Add code editor setting dropdowns#36534
Conversation
Add `<select>` controls for indent style (spaces/tabs), indent size (2/4/8), and line wrap mode to the code editor header. The git hooks editor is restyled to include this new header. Also included it a bugfix for the hooks editor where monaco was not configured correctly before. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds UI controls for configuring editor settings (indent style, indent size, and line wrap) to the code editor, git patch editor, and git hooks editor. It also includes a bugfix for the git hooks editor where Monaco was not configured with baseOptions before.
Changes:
- Added select controls for indent style, indent size, and line wrap mode to all code editors
- Refactored editorconfig data handling to pass slices instead of pre-joined strings to templates
- Fixed git hooks editor to properly apply baseOptions
- Simplified editorconfig indentation handling by keeping indentSize and tabSize in sync
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| web_src/js/features/codeeditor.ts | Added indentSize: 'tabSize' to baseOptions, moved baseOptions application to createMonaco (fixing git hooks), added event listeners for editor settings controls, simplified editorconfig tab size handling |
| templates/repo/settings/githook_edit.tmpl | Restructured to wrap content in form and include editor options in header |
| templates/repo/editor/patch.tmpl | Added header structure with editor options controls |
| templates/repo/editor/options.tmpl | New template containing select controls for indent style, indent size, and line wrap mode |
| templates/repo/editor/edit.tmpl | Added flex layout to header and included editor options |
| routers/web/repo/editor_util.go | Modified getContextRepoEditorConfig to return both JSON string and definition object |
| routers/web/repo/editor.go | Updated to set EditorconfigIndentStyle and EditorconfigIndentSize context data, changed to pass slices instead of joined strings for PreviewableExtensions and LineWrapExtensions |
| options/locale/locale_en-US.json | Added localization strings for editor settings controls |
| modules/templates/helper.go | Added PathExt template function |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: silverwind <me@silverwind.io>
Signed-off-by: silverwind <me@silverwind.io>
Signed-off-by: silverwind <me@silverwind.io>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
It seems it used an original menu which has a different style with other menus? |
|
Yes, this is because GitHub also uses bare |
Convert editor option selects from plain <select> elements to div-based Fomantic UI dropdowns with tooltips showing the option labels previously used as optgroup headers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Changed to use fomantic dropdowns:
|
Selection dropdown menus connect flush to the dropdown box, so the first item should not have rounded top corners. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevent font-weight and font-family from .ui.header parents propagating into the editor option dropdowns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Fixed the border radius issue. There are more issues related to fomantic dropdowns like it resizing on open or the misaligned dropdown right border, but I will defer those to another time to not blow this PR out of scope. |
|
Before reviewing, the general idea looks good. |
|
Mobile does not have enough space to fit this into one line. Maybe if the buttons before are reduced to just "Edit" and "Preview", then there might be enough space to fit a single dropdown but it will be hard if not impossible to condense the text enough. |
Add small, compact classes and override min-height and padding to bring dropdown height in line with adjacent menu items. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
All issues resolved. @wxiaoguang lgty? |
Signed-off-by: silverwind <me@silverwind.io>
Signed-off-by: silverwind <me@silverwind.io>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Avoid overriding Monaco's indentation detection with a fallback tabSize of 4 when EditorConfig doesn't define indent_style/indent_size. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Screen readers could announce these as unnamed comboboxes since optgroup label is not a reliable accessible name. Add localized aria-label attributes to each select element. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
lgtm |
* origin/main: (34 commits) Fine tune diff highlighting (go-gitea#36592) Add code editor setting dropdowns (go-gitea#36534) Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588) Improve diff highlighting (go-gitea#36583) Fix markup code block layout (go-gitea#36578) Remove striped tables in UI (go-gitea#36509) Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570) Fix mirror sync parser and fix mirror messages (go-gitea#36504) Update JS and PY deps (go-gitea#36576) Add viewer controller for mermaid (zoom, drag) (go-gitea#36557) Misc typescript tweaks (go-gitea#36523) Use full-file highlighting for diff sections (go-gitea#36561) fix(diff): reprocess htmx content after loading more files (go-gitea#36568) [skip ci] Updated translations via Crowdin Add wrap to runner label list (go-gitea#36565) fix: add dnf5 command for Fedora in RPM package instructions (go-gitea#36527) Enable pagination on GiteaDownloader.getIssueReactions() (go-gitea#36549) Refactor merge conan and container auth preserve actions taskID (go-gitea#36560) Fix assignee sidebar links and empty placeholder after go-gitea#32465 refactor (go-gitea#36559) Fix various version parsing problems (go-gitea#36553) ...
* origin/main: (152 commits) Fine tune diff highlighting (go-gitea#36592) Add code editor setting dropdowns (go-gitea#36534) Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588) Improve diff highlighting (go-gitea#36583) Fix markup code block layout (go-gitea#36578) Remove striped tables in UI (go-gitea#36509) Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570) Fix mirror sync parser and fix mirror messages (go-gitea#36504) Update JS and PY deps (go-gitea#36576) Add viewer controller for mermaid (zoom, drag) (go-gitea#36557) Misc typescript tweaks (go-gitea#36523) Use full-file highlighting for diff sections (go-gitea#36561) fix(diff): reprocess htmx content after loading more files (go-gitea#36568) [skip ci] Updated translations via Crowdin Add wrap to runner label list (go-gitea#36565) fix: add dnf5 command for Fedora in RPM package instructions (go-gitea#36527) Enable pagination on GiteaDownloader.getIssueReactions() (go-gitea#36549) Refactor merge conan and container auth preserve actions taskID (go-gitea#36560) Fix assignee sidebar links and empty placeholder after go-gitea#32465 refactor (go-gitea#36559) Fix various version parsing problems (go-gitea#36553) ...
* origin/main: (2555 commits) automate updating nix flakes (go-gitea#35641) Update AGENTS.md instructions (go-gitea#36627) use user id in noreply emails (go-gitea#36550) feat(db): Improve BuildCaseInsensitiveLike with lowercase (go-gitea#36598) [skip ci] Updated translations via Crowdin BUG: Fix workflow run jobs API returning null steps (go-gitea#36603) Refactor highlight and diff (go-gitea#36599) Fix bug when do LFS GC (go-gitea#36500) feature to be able to filter project boards by milestones (go-gitea#36321) Update emoji data for Unicode 16 (go-gitea#36596) Adapt monaco error matching pattern to recent webpack config change (go-gitea#36533) Fix a bug user could change another user's primary email (go-gitea#36586) fix(repo-editor): disable Monaco `editContext` to avoid bugs with lost focus (go-gitea#36585) Fine tune diff highlighting (go-gitea#36592) Add code editor setting dropdowns (go-gitea#36534) Update to go 1.26.0 and golangci-lint 2.9.0 (go-gitea#36588) Improve diff highlighting (go-gitea#36583) Fix markup code block layout (go-gitea#36578) Remove striped tables in UI (go-gitea#36509) Fix vertical alignment of `.commit-sign-badge` children (go-gitea#36570) ... # Conflicts: # custom/conf/app.example.ini # docs/content/administration/config-cheat-sheet.en-us.md # docs/content/administration/config-cheat-sheet.zh-cn.md # modules/setting/security.go # routers/common/errpage.go # services/context/api.go # services/context/context.go
Adds three `<select>` controls on top right for indent style, indent size, and line wrap to the code editor (`_edit`), diff patch editor (`_diffpatch`) and git hook editor (`/settings/hooks/git/pre-receive`). The git hooks editor is restyled to wrap the content in a box. Also included is a bugfix for the git hooks editor where monaco was not initialized correctly. --------- Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>






Adds three
<select>controls on top right for indent style, indent size, and line wrap to the code editor (_edit), diff patch editor (_diffpatch) and git hook editor (/settings/hooks/git/pre-receive).The git hooks editor is restyled to wrap the content in a box. Also included is a bugfix for the git hooks editor where monaco was not initialized correctly.
View with: https://github.com/go-gitea/gitea/pull/36534/changes?w=1