0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-07 01:43:24 +02:00
This commit is contained in:
silverwind 2025-12-17 20:23:15 +01:00
parent 4f9c25be31
commit 8fcfbb752a
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443

View File

@ -53,7 +53,7 @@ function isMonospaceEnabled() {
} }
/** Apply font variant to the provided or all textareas on the page */ /** Apply font variant to the provided or all textareas on the page */
function applyFontVariant(monospaceEnabled: boolean, textarea?: HTMLTextAreaElement) { function applyFont(monospaceEnabled: boolean, textarea?: HTMLTextAreaElement) {
for (const el of textarea ? [textarea] : document.querySelectorAll('.markdown-text-editor')) { for (const el of textarea ? [textarea] : document.querySelectorAll('.markdown-text-editor')) {
el.classList.toggle('tw-font-mono', monospaceEnabled); el.classList.toggle('tw-font-mono', monospaceEnabled);
} }
@ -155,14 +155,14 @@ export class ComboMarkdownEditor {
const monospaceButton = this.container.querySelector('.markdown-switch-monospace')!; const monospaceButton = this.container.querySelector('.markdown-switch-monospace')!;
const monospaceEnabled = isMonospaceEnabled(); const monospaceEnabled = isMonospaceEnabled();
applyFontVariant(monospaceEnabled, this.textarea); applyFont(monospaceEnabled, this.textarea);
const monospaceText = monospaceButton.getAttribute(monospaceEnabled ? 'data-disable-text' : 'data-enable-text')!; const monospaceText = monospaceButton.getAttribute(monospaceEnabled ? 'data-disable-text' : 'data-enable-text')!;
monospaceButton.setAttribute('data-tooltip-content', monospaceText); monospaceButton.setAttribute('data-tooltip-content', monospaceText);
monospaceButton.setAttribute('aria-checked', String(monospaceEnabled)); monospaceButton.setAttribute('aria-checked', String(monospaceEnabled));
monospaceButton.addEventListener('click', (e) => { monospaceButton.addEventListener('click', (e) => {
e.preventDefault(); e.preventDefault();
const enabled = !isMonospaceEnabled(); const enabled = !isMonospaceEnabled();
applyFontVariant(enabled); applyFont(enabled);
const text = monospaceButton.getAttribute(enabled ? 'data-disable-text' : 'data-enable-text')!; const text = monospaceButton.getAttribute(enabled ? 'data-disable-text' : 'data-enable-text')!;
monospaceButton.setAttribute('data-tooltip-content', text); monospaceButton.setAttribute('data-tooltip-content', text);
monospaceButton.setAttribute('aria-checked', String(enabled)); monospaceButton.setAttribute('aria-checked', String(enabled));