Skip to content

Fix and enhance comment editor monospace toggle#36181

Merged
wxiaoguang merged 22 commits intogo-gitea:mainfrom
silverwind:mono
Jan 26, 2026
Merged

Fix and enhance comment editor monospace toggle#36181
wxiaoguang merged 22 commits intogo-gitea:mainfrom
silverwind:mono

Conversation

@silverwind
Copy link
Member

@silverwind silverwind commented Dec 17, 2025

Fixes: #36175

  1. Correctly apply setting on textareas spawned by comment edit
  2. When changing the setting, apply it to all textareas on the current page

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 17, 2025
@silverwind
Copy link
Member Author

silverwind commented Dec 17, 2025

I think this could be expanded to also apply the setting in other open tabs by leveraging the storage event:

https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event

I guess a small storage helper module is needed to abstract this out of the file and be useful for all localStorage-backed variables.

@silverwind silverwind added type/enhancement An improvement of existing functionality and removed type/bug labels Dec 17, 2025
@silverwind
Copy link
Member Author

silverwind commented Dec 17, 2025

I've added the bare minimum to get the setting working across tabs too. There's probably an opportunity to abstract into some localStorage module suitable for more similar localStorage-backed settings, but I'm not totally certain how to design it.

@silverwind silverwind changed the title Fix comment editor monospace toggle for edit mode Fix and enhance comment editor monospace toggle Dec 17, 2025
@silverwind
Copy link
Member Author

web_src/js/modules/storage.ts is now contains minimal localStorage wrapper functions and I've used them everywhere where we previously used localStorage directly (except inline scripts, but that's another topic to be solved via web components). This is in preparation so that these settings can be synced to the server in the future.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Dec 21, 2025
@github-actions github-actions bot added the modifies/templates This PR modifies the template files label Jan 26, 2026
@wxiaoguang
Copy link
Contributor

To make code maintainable: b32c75f

@silverwind
Copy link
Member Author

silverwind commented Jan 26, 2026

Instead of all these get<Type> functions, we could let TypeScript handle it for us. a is string and b is number, it works like magic.

@wxiaoguang
Copy link
Contributor

Instead of all these get<Type> functions, we could let TypeScript handle it for us. a is string and b is number, it works like magic.

It doesn't work. Or, you can make changes as your proposal.

@wxiaoguang
Copy link
Contributor

a is string and b is number, it works like magic.

It won't work like magic because our code needs to handle string parsing (not simply use the local storage value as-is).

I believe the current design is good enough, easy to use and error-proof. So I think we can get it merged.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jan 26, 2026
@wxiaoguang wxiaoguang added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jan 26, 2026
@silverwind
Copy link
Member Author

silverwind commented Jan 26, 2026

Hmm fine, I still think Typescript could be leveraged and that functions like GetString have no right to exist in a sound type system.

@silverwind
Copy link
Member Author

Assuming we will sync to server later, I would not name it localUserSettings but userSettings.

@silverwind silverwind removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jan 26, 2026
@wxiaoguang
Copy link
Contributor

Assuming we will sync to server later, I would not name it localUserSettings but userSettings.

I believe no at the moment. Because when that time reaches, the design will be quite different.

And since there is TypeScript type checking, it is easier to rewrite in the future.

@silverwind
Copy link
Member Author

Assuming we will sync to server later, I would not name it localUserSettings but userSettings.

I believe no at the moment. Because when that time reaches, the design will be quite different.

And since there is TypeScript type checking, it is easier to rewrite in the future.

I guess it's actually ok because these settings are always kept local currently, so we can later rename the var to fit.

@silverwind
Copy link
Member Author

lgtm

@wxiaoguang wxiaoguang enabled auto-merge (squash) January 26, 2026 14:01
@wxiaoguang wxiaoguang merged commit 59f812b into go-gitea:main Jan 26, 2026
24 checks passed
@wxiaoguang wxiaoguang deleted the mono branch January 26, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend modifies/templates This PR modifies the template files type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Monospace font settings broken in comment/issue editor

5 participants