Fix and enhance comment editor monospace toggle (#36181)

Fixes: https://github.com/go-gitea/gitea/issues/36175

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

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-01-26 15:19:47 +01:00
committed by GitHub
parent 4c8f6dfa4e
commit 59f812bc1c
10 changed files with 120 additions and 36 deletions

View File

@@ -8,6 +8,7 @@ import {renderAnsi} from '../render/ansi.ts';
import {POST, DELETE} from '../modules/fetch.ts';
import type {IntervalId} from '../types.ts';
import {toggleFullScreen} from '../utils.ts';
import {localUserSettings} from '../modules/user-settings.ts';
// see "models/actions/status.go", if it needs to be used somewhere else, move it to a shared file like "types/actions.ts"
type RunStatus = 'unknown' | 'waiting' | 'running' | 'success' | 'failure' | 'cancelled' | 'skipped' | 'blocked';
@@ -71,15 +72,6 @@ type LocaleStorageOptions = {
expandRunning: boolean;
};
function getLocaleStorageOptions(): LocaleStorageOptions {
try {
const optsJson = localStorage.getItem('actions-view-options');
if (optsJson) return JSON.parse(optsJson);
} catch {}
// if no options in localStorage, or failed to parse, return default options
return {autoScroll: true, expandRunning: false};
}
export default defineComponent({
name: 'RepoActionView',
components: {
@@ -106,7 +98,8 @@ export default defineComponent({
},
data() {
const {autoScroll, expandRunning} = getLocaleStorageOptions();
const defaultViewOptions: LocaleStorageOptions = {autoScroll: true, expandRunning: false};
const {autoScroll, expandRunning} = localUserSettings.getJsonObject('actions-view-options', defaultViewOptions);
return {
// internal state
loadingAbortController: null as AbortController | null,
@@ -224,7 +217,7 @@ export default defineComponent({
methods: {
saveLocaleStorageOptions() {
const opts: LocaleStorageOptions = {autoScroll: this.optionAlwaysAutoScroll, expandRunning: this.optionAlwaysExpandRunning};
localStorage.setItem('actions-view-options', JSON.stringify(opts));
localUserSettings.setJsonObject('actions-view-options', opts);
},
// get the job step logs container ('.job-step-logs')